Files
T
2026-09-16 23:20:08 +07:00

35 lines
805 B
PHP

<?php
namespace App\Models;
/**
* Class Service
* Massage Service & Package Model
*
* @package App\Models
*/
class Service extends Model
{
protected string $table = 'services';
/**
* Get all active services for a branch
*/
public function getActive(int $branchId = null): array
{
$sql = "SELECT * FROM `{$this->table}`
WHERE `is_active` = 1 AND (`branch_id` IS NULL OR `branch_id` = :bid)
ORDER BY `category` ASC, `price` ASC";
$stmt = self::getDB()->prepare($sql);
$stmt->execute(['bid' => $branchId ?: 1]);
return $stmt->fetchAll();
}
/**
* Find by Service Code
*/
public function findByCode(string $code): ?array
{
return $this->firstWhere(['code' => $code]);
}
}