Skip to content

Commit

Permalink
Added Image Attribute
Browse files Browse the repository at this point in the history
Due to this function images can show in frontend and admin both.
  • Loading branch information
chiragpipariya authored Aug 27, 2018
1 parent 84e9191 commit 95c18df
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Modules/Page/Entities/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@ public function __call($method, $parameters)
#i: No relation found, return the call to parent (Eloquent) to handle it.
return parent::__call($method, $parameters);
}

public function getImageAttribute()
{
$thumbnail = $this->files()->where('zone', 'image')->first();

if ($thumbnail === null) {
return '';
}

return $thumbnail;
}
}

0 comments on commit 95c18df

Please sign in to comment.