*/ use HasFactory; use HasRecursiveRelationships; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'parent_id', 'is_file', 'name', 'extension', 'content', ]; /** * Get the associated vault. * * @return BelongsTo */ public function vault(): BelongsTo { return $this->belongsTo(Vault::class); } /** * Get the childs for the node. * * @return HasMany */ public function childs(): HasMany { return $this->hasMany(self::class, 'parent_id'); } /** * The nodes that are linked to the node. * * @return BelongsToMany */ public function links(): BelongsToMany { return $this->belongsToMany(self::class, null, 'source_id', 'destination_id'); } /** * The nodes that are backlinked to the node. * * @return BelongsToMany */ public function backlinks(): BelongsToMany { return $this->belongsToMany(self::class, null, 'destination_id', 'source_id'); } /** * The tags that are linked to the node. * * @return BelongsToMany */ public function tags(): BelongsToMany { return $this->belongsToMany(Tag::class, null, 'vault_node_id', 'tag_id'); } /** * Get the custom paths for the model. * * @return list */ public function getCustomPaths(): array { return [ [ 'name' => 'full_path', 'column' => 'name', 'separator' => '/', 'reverse' => true, ], ]; } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'is_file' => 'boolean', ]; } }