The Model

Setup

Include below code on your model

use \Vortechron\Essentials\Traits\ModelEssentials;

Or

use \Vortechron\Essentials\Traits\HasMedia;
use \Vortechron\Essentials\Traits\Modeler;

Those traits add the ability to standardize your model with vfg. But behind the scene, we just normalize model attribute for front end.

Full Example

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia\HasMedia;
class Page extends Model implements HasMedia
{
use \Vortechron\Essentials\Traits\ModelEssentials;
protected $fillable = ['slug', 'title', 'content', 'social_title', 'social_description'];
protected $appends = ['social_image'];
public function getSocialImageAttribute()
{
return $this->getMedia('social');
}
}

For Model

protected $for_model = ['categories'];
public function getCategoriesForModel()
{
// return categories list
}
// results
[
'_data_categories' => [...]
]