This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
use App\Support\Enrollment\DeliberationDecision;
|
||||
|
||||
class StudentDecisionModel extends Model
|
||||
{
|
||||
@@ -18,6 +19,7 @@ class StudentDecisionModel extends Model
|
||||
'class_section_name',
|
||||
'year_score',
|
||||
'decision',
|
||||
'deliberation_decision_standard',
|
||||
'source',
|
||||
'notes',
|
||||
'generated_by',
|
||||
@@ -30,4 +32,18 @@ class StudentDecisionModel extends Model
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user