z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

Form field To Laravel9 Attribute error #5621

Closed kkkreset closed 2 years ago

kkkreset commented 2 years ago

Description:

Error using attribute for form field.

Steps To Reproduce:

` $form->image('pic', __('pic'))->required()->name(function($file) { return md5('product_pic'.time().rand(0, 10000)).'.'.$file->guessExtension(); })->setElementClass(md5(microtime(true)));

public function pic(): Attribute
{
    return new Attribute(
        get: function($value) {
            return  $value;
        }
    );
}`

ERRIR: Call to undefined method Illuminate\Database\Eloquent\Casts\Attribute::addEagerConstraints()