'datetime', 'date_end' => 'datetime', ]; protected $fillable = [ 'title', 'text', 'picture_home', 'alt_text_picture_home', 'picture_news', 'alt_text_picture_news', 'date_start', 'date_end', 'on_top' ]; protected static function boot() { static::creating(function (Post $post) { if ($post->picture_home) { $post->picture_home = Utils::storeImage($post->picture_home, $post->getTable()); } if ($post->picture_news) { $post->picture_news = Utils::storeImage($post->picture_news, $post->getTable()); } }); static::updating(function (Post $post) { if ($post->picture_home) { $post->picture_home = Utils::storeImage($post->picture_home, $post->getTable()); } if ($post->picture_news) { $post->picture_news = Utils::storeImage($post->picture_news, $post->getTable()); } }); parent::boot(); } }