Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 10 Call to undefined method when add attribute function #3

Open
teoprayoga opened this issue Jul 24, 2024 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@teoprayoga
Copy link

teoprayoga commented Jul 24, 2024

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 teoprayoga added the bug Something isn't working label Jul 24, 2024
@sebastiaanluca
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants