. */ namespace Modules\Articoli; use Common\SimpleModelTrait; use Illuminate\Database\Eloquent\Model; use Traits\HierarchyTrait; class Categoria extends Model { use SimpleModelTrait; use HierarchyTrait; protected $table = 'mg_categorie'; protected static $parent_identifier = 'parent'; public static function build($nome) { $model = new static(); $model->nome = $nome; $model->save(); return $model; } public function articoli() { return $this->hasMany(Articolo::class, 'id_categoria'); } }