Refactor featured image handling in Page model and update PagesTable: Renamed 'featured_image' to 'featured_image_url' in PagesTable for clarity. Added a new accessor method in the Page model to generate the URL for the featured image.
This commit is contained in:
@@ -63,4 +63,13 @@ class Page extends Model
|
||||
|
||||
return '/' . $this->slug;
|
||||
}
|
||||
|
||||
public function getFeaturedImageUrlAttribute()
|
||||
{
|
||||
if ($this->featured_image) {
|
||||
return asset('storage/' . $this->featured_image);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user