<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SupplierCaseStudy extends Model
{
    use HasFactory;

    protected $fillable = [
        'supplier_name',
        'category',
        'title',
        'excerpt',
        'content',
        'image_path',
        'metrics',
        'is_featured',
        'is_active',
    ];

    protected $casts = [
        'is_featured' => 'boolean',
        'is_active' => 'boolean',
    ];

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