You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling isRelation() on a model, to test if a certain key is a relation, the function returns wrongly true when a Accessor-method is present.
Steps To Reproduce:
<?phpnamespaceApp\Models;
useIlluminate\Database\Eloquent\Casts\Attribute;
useIlluminate\Database\Eloquent\Model;
class User extends Model
{
protectedfunctionmyname(): Attribute
{
returnnewAttribute(
get: fn () => 'some value'
);
}
}
And than, somewhere in your application call this
dd($user->isRelation('myname')); // returns TRUE
Since 'myname' is not a relation, but a Accessor, it is expected that isRelation() should return false.
A possible fix would be to do an extra check in the isRelation() method to test if a method is not a Accessor, but I'm not sure what's the best approach to do that.
The text was updated successfully, but these errors were encountered:
Description:
When calling
isRelation()
on a model, to test if a certain key is a relation, the function returns wronglytrue
when a Accessor-method is present.Steps To Reproduce:
And than, somewhere in your application call this
Since 'myname' is not a relation, but a Accessor, it is expected that
isRelation()
should returnfalse
.A possible fix would be to do an extra check in the
isRelation()
method to test if a method is not a Accessor, but I'm not sure what's the best approach to do that.The text was updated successfully, but these errors were encountered: