I have model Post with attributes: id, content, image, publish_date
.
In the Post model I can get all attributes but image when using $this->$attr
it shows me Undefined property when calling $this->image. I don't know why. But when I call in the Controller: Post::find(1)->image
, it works fine.
Can anyone help me pls?
Since you're using an accessor, try to do this:
public function getImageAttribute($value)
{
dd($value);
}
This was the first link that showed up in my google search, so I am posting the solution I found here as well, for anyone else running into the same issue.
In relation to the question above, I would have had to use $this->attributes['image']
, specifically for accessing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With