Files
alrahma_sunday_school/app/Models/StudentDecisionModel.php
T
root 1ef2800f12
Tests / PHPUnit (push) Successful in 1m26s
fix enrollment for the new school-year
2026-08-07 23:43:31 -04:00

50 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
use App\Models\Concerns\SchoolYearAutoFillTrait;
use App\Support\Enrollment\DeliberationDecision;
class StudentDecisionModel extends Model
{
use SchoolYearAutoFillTrait;
protected $table = 'student_decisions';
protected $primaryKey = 'id';
protected $allowedFields = [
'student_id',
'school_year',
'class_section_name',
'year_score',
'decision',
'deliberation_decision_standard',
'source',
'notes',
'generated_by',
];
protected $validationRules = [
'school_year' => 'required|string|max_length[9]',
];
protected $useTimestamps = true;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $beforeInsert = ['standardizeDeliberationDecision'];
protected $beforeUpdate = ['standardizeDeliberationDecision'];
protected function standardizeDeliberationDecision(array $data): array
{
if (
array_key_exists('decision', $data['data'] ?? [])
&& $this->db->fieldExists('deliberation_decision_standard', $this->table)
) {
$data['data']['deliberation_decision_standard'] = DeliberationDecision::normalize($data['data']['decision'] ?? null);
}
return $data;
}
}