corcel / corcel/corcel

Trying to get property 'guid' of non-object.

Open
#608 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
4.8k
Forks
600
PR merge metrics
No merged PRs in 30d

Description

- 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()`.

I got the error as shown in the screenshot below
Screenshot 2022-03-09 at 02 44 46

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.