<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Package extends Model
{
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'en_name',
        'fa_name',
        'thumbnail',
        'en_description',
        'fa_description',
        'price',
        'discount',
        'slug',
        'is_featured',
        'is_active',
        'package_category_id',
    ];

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'id' => 'integer',
            'thumbnail' => 'array',
            'is_featured' => 'boolean',
            'is_active' => 'boolean',
            'package_category_id' => 'integer',
        ];
    }

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

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