First Commit
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class UserNotification extends Model
|
||||
{
|
||||
protected $fillable = ['user_id', 'type', 'title', 'message', 'is_read', 'read_at'];
|
||||
|
||||
protected $casts = [
|
||||
'is_read' => 'boolean',
|
||||
'read_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo { return $this->belongsTo(User::class); }
|
||||
|
||||
public function markAsRead(): void
|
||||
{
|
||||
$this->update(['is_read' => true, 'read_at' => now()]);
|
||||
}
|
||||
|
||||
public function typeIcon(): string
|
||||
{
|
||||
return match ($this->type) {
|
||||
'payment_due' => '💰',
|
||||
'payment_overdue' => '🔴',
|
||||
'subscription_expiring' => '⚠️',
|
||||
'subscription_expired' => '🚫',
|
||||
'payment_received' => '✅',
|
||||
'admin_message' => '📢',
|
||||
'new_registration' => '👋',
|
||||
default => '📌',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user