*/ protected $fillable = [ 'name', 'bits', 'description', 'parent_id', ]; /** * The attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'parent_id' => 'integer', ]; } public function children(): HasMany { return $this->hasMany(Permission::class, 'parent_id'); } public function parent(): BelongsTo { return $this->belongsTo(Permission::class, 'parent_id'); } }