<?php
declare(strict_types=1);

namespace App\Modules\ServiceCatalog\Models;

use App\Core\Model;
use App\Core\App;

class ServicePrice extends Model
{
    protected static string $table = 'service_catalog';
    protected static bool $softDelete = false;
    protected static bool $timestamps = true;
    protected static array $fillable = [
        'service_code', 'name_ar', 'name_en', 'price_type', 'base_amount',
        'percentage', 'annual_amount', 'currency', 'applies_to', 'branch_id',
        'effective_from', 'effective_to', 'is_active',
    ];

    public static function allActive(): array
    {
        $db = App::getInstance()->db();
        return $db->select("
            SELECT sc.*, b.name_ar as branch_name
            FROM service_catalog sc
            LEFT JOIN branches b ON b.id = sc.branch_id
            WHERE sc.is_active = 1
            ORDER BY sc.service_code
        ");
    }
}