Files
boursecu_server/app/Models/AppNotification.php
T
2026-07-24 22:37:48 +03:30

49 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class AppNotification extends Model
{
use SoftDeletes;
protected $table = 'app_notifications';
protected $fillable = [
'title',
'body',
'severity',
'is_active',
'created_by',
'audience_type',
'segment_keys',
'audience_label',
'recipients_count',
];
protected $casts = [
'is_active' => 'boolean',
'segment_keys' => 'array',
'recipients_count' => 'integer',
];
public function reads(): HasMany
{
return $this->hasMany(AppNotificationRead::class, 'notification_id');
}
public function recipients(): HasMany
{
return $this->hasMany(AppNotificationRecipient::class, 'notification_id');
}
public function creator(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
}