50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class FinancialAidRequestModel extends Model
|
|
{
|
|
protected $table = 'financial_aid_requests';
|
|
protected $primaryKey = 'id';
|
|
protected $returnType = 'array';
|
|
protected $useTimestamps = true;
|
|
|
|
protected $allowedFields = [
|
|
'parent_id',
|
|
'school_year',
|
|
'student_ids_json',
|
|
'household_size',
|
|
'need_statement',
|
|
'requested_amount',
|
|
'status',
|
|
'admin_amount',
|
|
'admin_note',
|
|
'reviewed_by',
|
|
'reviewed_at',
|
|
'invoice_id',
|
|
'discount_usage_id',
|
|
'voucher_id',
|
|
'created_at',
|
|
'updated_at',
|
|
];
|
|
|
|
public function openRequestForParent(int $parentId, string $schoolYear): ?array
|
|
{
|
|
return $this->where('parent_id', $parentId)
|
|
->where('school_year', $schoolYear)
|
|
->whereIn('status', ['submitted', 'under_review'])
|
|
->orderBy('id', 'DESC')
|
|
->first();
|
|
}
|
|
|
|
public function requestForParentYear(int $parentId, string $schoolYear): ?array
|
|
{
|
|
return $this->where('parent_id', $parentId)
|
|
->where('school_year', $schoolYear)
|
|
->orderBy('id', 'DESC')
|
|
->first();
|
|
}
|
|
}
|