<?php

namespace App\Models\Registries;

use App\Support\RelationValuesTrait;
use App\Support\UuidScopeTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Category extends Model {
    use UuidScopeTrait, SoftDeletes, RelationValuesTrait;

    protected $table = 'registry_categories';

    protected $dates = [
    ];

    protected $fillable = [
        'uuid',
        'registry_id',
        'parent_id',
        'name'
    ];

    protected $hidden = [
        'id'
    ];


    public function registry(): BelongsTo {
        return $this->belongsTo(Registry::class);
    }

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

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

    public function entries(): HasMany {
        return $this->hasMany(Entry::class);
    }



}
