<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;
use Spatie\Translatable\HasTranslations;

class Category extends Model implements Sortable
{
    use HasTranslations, SortableTrait, HasFactory;

    protected $table = "category";
    protected $hidden = ["created_at", "updated_at"];
    protected $guarded = [];

    public $translatable = ["name", "description"];

    public function products()
    {
        return $this->hasMany(Product::class);
    }

    public $sortable = [
        "order_column_name" => "sort_order",
        "sort_when_creating" => true,
    ];
}
