<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

final class ItemTemplate extends Model
{
    protected $table = 'item_templates';

    protected $fillable = [
        'name',
        'item_id',
        'item_name',
        'count',
        'proctype',
        'octet',
        'mask',
        'protect_type',
        'is_active',
    ];

    protected $casts = [
        'item_id' => 'integer',
        'count' => 'integer',
        'proctype' => 'integer',
        'mask' => 'integer',
        'protect_type' => 'integer',
        'is_active' => 'boolean',
    ];

    /**
     * Scope to get only active templates
     */
    public function scopeActive(Builder $query): Builder
    {
        return $query->where('is_active', true);
    }
}
