feat(admin): improve payments and server settings
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\AdminNotificationCreated;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Customer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Notification extends Model
|
||||
{
|
||||
@@ -58,5 +58,23 @@ class Notification extends Model
|
||||
...$attributes,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($adminIds->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
broadcast(new AdminNotificationCreated(
|
||||
type: (string) ($attributes['type'] ?? 'system'),
|
||||
title: (string) ($attributes['title'] ?? 'Có thông báo mới'),
|
||||
body: isset($attributes['body']) ? (string) $attributes['body'] : null,
|
||||
link: isset($attributes['link']) ? (string) $attributes['link'] : null,
|
||||
));
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('Không thể phát thông báo realtime cho quản trị viên.', [
|
||||
'type' => $attributes['type'] ?? null,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user