Файловый менеджер - Редактировать - /home/clickysoft/public_html/assets.clickysoft.net/app/Notifications/MaintenanceRequestNotification.php
Назад
<?php namespace App\Notifications; use Exception; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; use Illuminate\Notifications\Messages\DatabaseMessage; use GuzzleHttp\Client; class MaintenanceRequestNotification extends Notification implements ShouldQueue { use Queueable; /** * Create a new notification instance. */ protected $maintenanceRequest; protected $notification; protected $from; public function __construct($maintenanceRequest) { $this->maintenanceRequest = $maintenanceRequest; $this->from = auth()->id(); $this->notification = [ 'key' => $maintenanceRequest->id, 'label' => 'A new maintenance request has been submitted.', 'url' => "/maintenance-requests/" . $maintenanceRequest->id, 'from' => $this->from, ]; } /** * Get the notification's delivery channels. * * @return array<int, string> */ public function via(object $notifiable): array { return ['mail', 'database']; // , 'websocket' } /** * Get the mail representation of the notification. */ public function toMail(object $notifiable): MailMessage { return (new MailMessage)->view('emails.maintenance-request', ['maintenanceRequest' => $this->maintenanceRequest])->subject(env("APP_NAME") . " - Maintenance Request Received."); } public function toDatabase($notifiable) { $notificationMessage = new DatabaseMessage($this->notification); $notification = $notifiable->notifications()->latest()->first(); $client = new Client(); try { $client->post(env("WEB_SOCKET_URL") . '/notify', [ 'json' => [ 'userId' => $notifiable->id, 'notification' => [ 'key' => $notification->id, 'label' => $notification->data['label'], 'redirectTo' => $notification->data['url'], 'read_at' => $notification->read_at, 'created_at' => $notification->created_at->diffForHumans(), 'from' => $this->from, ], 'count' => $notifiable->unreadNotifications()->count() + 1 ] ]); } catch (Exception $e) { \Log::info($e->getMessage()); } return $notificationMessage; } /** * Get the array representation of the notification. * * @return array<string, mixed> */ public function toArray(object $notifiable): array { return [ // ]; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка