|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
+use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
@@ -20,6 +21,20 @@ class NotificationDeliveryLog extends Model
|
|
|
public const STATUS_SKIPPED = 'skipped';
|
|
|
public const STATUS_DEAD_LETTER = 'dead_letter';
|
|
|
|
|
|
+ public const CHANNEL_LABELS = [
|
|
|
+ self::CHANNEL_IN_APP => 'В приложении',
|
|
|
+ self::CHANNEL_BROWSER => 'Браузер',
|
|
|
+ self::CHANNEL_PUSH => 'Push',
|
|
|
+ self::CHANNEL_EMAIL => 'Email',
|
|
|
+ ];
|
|
|
+
|
|
|
+ public const STATUS_LABELS = [
|
|
|
+ self::STATUS_SENT => 'Отправлено',
|
|
|
+ self::STATUS_FAILED => 'Ошибка',
|
|
|
+ self::STATUS_SKIPPED => 'Пропущено',
|
|
|
+ self::STATUS_DEAD_LETTER => 'Dead letter',
|
|
|
+ ];
|
|
|
+
|
|
|
public const DEFAULT_SORT_BY = 'created_at';
|
|
|
public const DEFAULT_ORDER_BY = 'desc';
|
|
|
|
|
|
@@ -33,6 +48,20 @@ class NotificationDeliveryLog extends Model
|
|
|
'error',
|
|
|
];
|
|
|
|
|
|
+ protected function channel(): Attribute
|
|
|
+ {
|
|
|
+ return Attribute::make(
|
|
|
+ get: fn($value) => self::CHANNEL_LABELS[$value] ?? $value,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function status(): Attribute
|
|
|
+ {
|
|
|
+ return Attribute::make(
|
|
|
+ get: fn($value) => self::STATUS_LABELS[$value] ?? $value,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
public function user(): BelongsTo
|
|
|
{
|
|
|
return $this->belongsTo(User::class);
|