5e35fefd69
API CI/CD / Validate (composer + pint) (push) Successful in 2m47s
API CI/CD / Test (PHPUnit) (push) Failing after 3m8s
API CI/CD / Build frontend assets (push) Failing after 5m22s
API CI/CD / Security audit (push) Failing after 34s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Records each reminder dispatched to parents for an open promotion
|
|
* record (see plan section 14).
|
|
*/
|
|
class PromotionReminderLog extends BaseModel
|
|
{
|
|
protected $table = 'promotion_reminders_log';
|
|
|
|
public $timestamps = true;
|
|
|
|
public const TYPE_FIRST = 'first';
|
|
|
|
public const TYPE_HALFWAY = 'halfway';
|
|
|
|
public const TYPE_FINAL = 'final';
|
|
|
|
public const TYPE_EXPIRATION = 'expiration';
|
|
|
|
public const TYPE_MANUAL = 'manual';
|
|
|
|
public const ALLOWED_TYPES = [
|
|
self::TYPE_FIRST,
|
|
self::TYPE_HALFWAY,
|
|
self::TYPE_FINAL,
|
|
self::TYPE_EXPIRATION,
|
|
self::TYPE_MANUAL,
|
|
];
|
|
|
|
protected $fillable = [
|
|
'promotion_id',
|
|
'student_id',
|
|
'parent_id',
|
|
'reminder_type',
|
|
'channel',
|
|
'subject',
|
|
'message',
|
|
'sent_at',
|
|
'sent_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'promotion_id' => 'integer',
|
|
'student_id' => 'integer',
|
|
'parent_id' => 'integer',
|
|
'sent_by' => 'integer',
|
|
'sent_at' => 'datetime',
|
|
];
|
|
|
|
public function setSubjectAttribute(?string $value): void
|
|
{
|
|
$this->attributes['subject'] = $value !== null ? strip_tags($value) : null;
|
|
}
|
|
|
|
public function setMessageAttribute(?string $value): void
|
|
{
|
|
$this->attributes['message'] = $value !== null ? strip_tags($value) : null;
|
|
}
|
|
|
|
public function promotion(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StudentPromotionRecord::class, 'promotion_id', 'promotion_id');
|
|
}
|
|
|
|
public function scopeForPromotion(Builder $q, int $promotionId): Builder
|
|
{
|
|
return $q->where('promotion_id', $promotionId);
|
|
}
|
|
}
|