add projet
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class ParentNotification extends BaseModel
|
||||
{
|
||||
protected $table = 'parent_notifications';
|
||||
protected $primaryKey = 'id';
|
||||
public $timestamps = true;
|
||||
const CREATED_AT = 'created_at';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'code',
|
||||
'incident_date',
|
||||
'channel',
|
||||
'to_address',
|
||||
'subject',
|
||||
'status',
|
||||
'response',
|
||||
'semester',
|
||||
'school_year',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function hasSent(int $studentId, string $code, string $incidentYmd, string $channel='email', ?string $to=null): bool
|
||||
{
|
||||
$qb = $this->where('student_id', $studentId)
|
||||
->where('code', $code)
|
||||
->where('incident_date', $incidentYmd)
|
||||
->where('channel', $channel);
|
||||
if ($to) $qb->where('to_address', $to);
|
||||
|
||||
$row = $qb->orderBy('id','DESC')->first();
|
||||
return $row && ($row['status'] ?? '') === 'sent';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user