fix notif 3

This commit is contained in:
2026-07-24 22:37:48 +03:30
parent 107cf5b291
commit 52ff3a088d
7 changed files with 493 additions and 32 deletions
+17
View File
@@ -3,6 +3,7 @@
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;
@@ -18,14 +19,30 @@ class AppNotification extends Model
'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');
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class AppNotificationRecipient extends Model
{
protected $table = 'app_notification_recipients';
protected $fillable = [
'notification_id',
'customer_id',
];
public function notification(): BelongsTo
{
return $this->belongsTo(AppNotification::class, 'notification_id');
}
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class, 'customer_id');
}
}