This commit is contained in:
2025-07-14 12:15:41 +03:00
parent a64ed080bb
commit 273ac72207
974 changed files with 483955 additions and 14 deletions

View File

@@ -0,0 +1,71 @@
<?php
namespace kernel\modules\notification\models;
use Illuminate\Database\Eloquent\Model;
use kernel\modules\user\models\User;
/**
* @property int $id
* @property int $user_id
* @property bool $is_read
* @property array|string $data
* @property string $type
* @property string $message
* @property string $subject
* @property int $status
*/
class Notification extends Model
{
const DISABLE_STATUS = 0;
const TO_SEND_STATUS = 1;
const SENT_STATUS = 2;
protected $table = 'notification';
protected $fillable = ['user_id', 'message', 'is_read', 'data', 'type', 'subject', 'status'];
protected $casts = [
'is_read' => 'boolean',
'data' => 'array'
];
public static function labels(): array
{
return [
'user_id' => 'Пользователь',
'message' => 'Сообщение',
'subject' => 'Тема',
'is_read' => 'Прочитано',
'data' => 'Данные',
'type' => 'Тип',
'status' => 'Статус'
];
}
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class);
}
public function markAsRead(): static
{
$this->update(['is_read' => true]);
return $this;
}
/**
* @return string[]
*/
public static function getStatus(): array
{
return [
self::DISABLE_STATUS => "Не активный",
self::TO_SEND_STATUS => "На отправку",
self::SENT_STATUS => "Отправлено",
];
}
}