29 lines
720 B
PHP
29 lines
720 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class DaysModel extends Model
|
|
{
|
|
protected $table = 'days';
|
|
protected $primaryKey = 'id';
|
|
protected $useAutoIncrement = true;
|
|
protected $returnType = 'array';
|
|
protected $useSoftDeletes = false;
|
|
protected $allowedFields = ['day_number', 'day_name'];
|
|
protected $useTimestamps = false;
|
|
|
|
// Get day name by day number
|
|
public function getDayName(int $dayNumber): ?string
|
|
{
|
|
return $this->where('day_number', $dayNumber)->first()['day_name'] ?? null;
|
|
}
|
|
|
|
// Get all days
|
|
public function getAllDays(): array
|
|
{
|
|
return $this->orderBy('day_number', 'ASC')->findAll();
|
|
}
|
|
}
|