Closed TiiFuchs closed 1 year ago
Could you share a small example app that demonstrates the problem? That will help us getting it fixed faster.
So I took another look this morning and I think I understand it now. It's more a laravel-ray issue and actually it's more like a user error than an actually issue. But I guess it could be fixed anyway. I'll let that for you to decide.
I created a test app and put it here: https://github.com/TiiFuchs/ray-test
Running php artisan test
throws this exception (no db needed for this): https://flareapp.io/share/17xj2kbm#F32
The problem is, that I used the camelCase version of the new Attribute like this: https://github.com/TiiFuchs/ray-test/blob/59ea5b550b6976375c24adddfe78b0a824fa9e81/app/Models/User.php#L49-L58
Ray expects this to be
protected $appends = [
'contact_line'
];
I didn't understand this at first, because Laravel seems to get along with the camelCase version just fine, but Ray didn't.
So the actual fix for the user is to just specify the attributes in $appends
as snake_case. But if you think it's worth it, ray can become a little bit more robust.
Dear contributor,
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.
Ray Version 2.0.1 Laravel Version 9.9.0
I have a Eloquent model that uses the new Attribute syntax of Laravel to create an Accessor See here.
When I add an
$appends
property to my Eloquent Model so the newly created accessor also gets added to the json representation, ray crashes with a BadMethodCallException.It tries to call getAttribute(), which does not exist, since I am using the version with
Illuminate\Database\Eloquent\Casts\Attribute
.I think this might be a bug.