laravel-boolean-dates icon indicating copy to clipboard operation
laravel-boolean-dates copied to clipboard

Laravel 10 Call to undefined method when add attribute function

Open teoprayoga opened this issue 1 year ago • 1 comments

Steps to reproduce

in my model adding 2 attribute protected $appends = [ 'is_close_by_admin', 'is_close_by_pic', ];

protected $casts = [ 'close_by_admin_at' => 'datetime', 'close_by_pic_at' => 'datetime', ];

add 2 function protected function isCloseByAdmin(): BooleanDateAttribute { return BooleanDateAttribute::for('close_by_admin_at'); }

And then another function

protected function isCloseByPic(): BooleanDateAttribute { return BooleanDateAttribute::for('close_by_pic_at'); }

Additional info

and then run some API that use this Model "message": "Call to undefined method App\\Models\\ProjectJob::getIsCloseByAdminAttribute()", "exception": "BadMethodCallException",

teoprayoga avatar Jul 24 '24 03:07 teoprayoga

Can you set up a new project using Laravel 10 with the code that fails and share the repo? I tried it locally and in the tests as best as I could with the information, but couldn't reproduce it. I also don't see any errors in your snippets so based on that information it should work though.

sebastiaanluca avatar Jul 25 '24 07:07 sebastiaanluca