Files
alrahma_sunday_school/app/Models/InventoryCategoryModel.php
T
root 716cc8b8d3
Tests / PHPUnit (push) Failing after 1m20s
fix school year for all tables
2026-07-18 14:45:38 -04:00

40 lines
958 B
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
use App\Models\Concerns\SchoolYearAutoFillTrait;
class InventoryCategoryModel extends Model
{
use SchoolYearAutoFillTrait;
protected $table = 'inventory_categories';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useTimestamps = true;
protected $allowedFields = [
'type',
'name',
'description',
'grade_min',
'grade_max',
'created_at',
'updated_at',
'school_year',
];
protected $validationRules = [
'school_year' => 'required|string|max_length[9]',
];
public function optionsForType(string $type): array
{
return $this->select('id, name, description, grade_min, grade_max')
->where('type', $type)
->orderBy('name', 'ASC')
->findAll(); // returnType already 'array'
}
}