<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

use App\Models\User;

class ImageNode extends Model
{
    use HasFactory;

    protected $table = 'image_nodes';
    protected $fillable = [
        'user_id',
        'parent_id',
        'name',
        'fs_type',
        'fs_meta',
    ];

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function children() {
        return $this->hasMany(ImageNode::class, 'parent_id', 'id');
    }

    public function parent() {
        return $this->belongsTo(ImageNode::class, 'parent_id', 'id');
    }
}
