'int', 'status' => 'int', 'object' => 'array' ]; protected $fillable = [ 'identifier', 'slug', 'referenz', 'action', 'object', 'full_text', 'text', 'status', 'type' ]; protected static $types = [ 'object' => 'Object', 'full_text' => 'Full Text', 'text' => 'Text', ]; public function sluggable() { return [ 'slug' => [ 'source' => 'name' ] ]; } public static function getContentBySlug($slug){ $content = self::whereSlug(trim($slug))->first(); if($content){ switch ($content->type){ case 'object': return $content->object; break; case 'full_text': return $content->full_text; break; case 'text': return $content->text; break; } } return false; } public static function setContentBySlug($slug, $value, $type = "full_text"){ $content = self::whereSlug(trim($slug))->first(); if(!$content) { $content = self::create([ 'slug' => $slug, 'type' => $type, ]); } $content->type = $type; switch ($content->type){ case 'object': $content->object = $value; break; case 'full_text': $content->full_text = $value; break; case 'text': $content->text = $value; break; } $content->save(); return $content; } }