<?php
namespace App\Models;

use App\Enums\TeamCategory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TeamMember extends Model
{
    use HasFactory;
    protected $fillable = ['name', 'role', 'category', 'bio', 'photo', 'sort_order', 'is_active'];

    protected function casts(): array
    {
        return [
            'category' => TeamCategory::class,
            'is_active' => 'boolean',
        ];
    }

    public function scopeActive($query)
    {
        return $query->where('is_active', true)->orderBy('sort_order');
    }

    public function scopeByCategory($query, TeamCategory $category)
    {
        return $query->where('category', $category);
    }
}
