Trying to get property 'guid' of non-object.
TheRealSageKing opened this issue · comments
- Corcel Version: 5.1.1
- Framework Name & Version: Laravel 9.0
- PHP Version: 7.4
- Database Driver & Version: MYSQL 8.0
Description:
I get the above error when i try to get featured image of a post with bad featured image.
Steps To Reproduce:
-
Install FakerPress (to generate random posts with featured images)
-
from laravel make a request to fetch all posts and display feature images
-
I used this method in my model to retrieve thumbnails
public function getPostThumbnail()
{
try{
if ( !is_null($this->meta->_thumbnail_id) )
{
return $this->thumbnail;
}
return asset('images/blog/1.jpg');
}catch(\Exception $ex)
{
return asset('images/blog/1.jpg');
}
}
so i can call it like so $post->getPostThumbnail()
.