<?php
declare(strict_types=1);

namespace App\Models;

final class PipelineStage extends BaseModel
{
    protected static string $table = 'pipeline_stages';
    protected static bool $softDelete = false;

    public static function allActive(): array
    {
        return static::db()->fetchAll(
            'SELECT * FROM pipeline_stages WHERE tenant_id = :tid AND is_active = 1 ORDER BY sort_order, id',
            ['tid' => static::tenantId()]
        );
    }

    public static function openStages(): array
    {
        return static::db()->fetchAll(
            'SELECT * FROM pipeline_stages WHERE tenant_id = :tid AND is_active = 1 AND is_won = 0 AND is_lost = 0 ORDER BY sort_order',
            ['tid' => static::tenantId()]
        );
    }
}
