laravel-boolean-dates
laravel-boolean-dates copied to clipboard
Laravel 10 Call to undefined method when add attribute function
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",
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.