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

54 lines
1.0 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
use App\Models\Concerns\SchoolYearAutoFillTrait;
class ClassModel extends Model
{
use SchoolYearAutoFillTrait;
protected $table = 'classes'; // The table name
protected $primaryKey = 'id'; // The correct primary key for the classes table
// Fields that are allowed to be manipulated.
protected $allowedFields = [
'class_name',
'schedule',
'capacity',
'school_year',
];
protected $validationRules = [
'school_year' => 'required|string|max_length[9]',
];
protected $useTimestamps = false;
public function getAllClasses()
{
return $this->findAll();
}
public function getClassById($id)
{
return $this->find($id);
}
public function createClass($data)
{
return $this->insert($data);
}
public function updateClass($id, $data)
{
return $this->update($id, $data);
}
public function deleteClass($id)
{
return $this->delete($id);
}
}
?>