55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Production\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
use App\Modules\Production\Models\ProductionOrder;
|
|
|
|
class NewProductionOrder extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
protected $productionOrder;
|
|
protected $creatorName;
|
|
|
|
/**
|
|
* Create a new notification instance.
|
|
*/
|
|
public function __construct(ProductionOrder $productionOrder, string $creatorName)
|
|
{
|
|
$this->productionOrder = $productionOrder;
|
|
$this->creatorName = $creatorName;
|
|
}
|
|
|
|
/**
|
|
* Get the notification's delivery channels.
|
|
*
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['database'];
|
|
}
|
|
|
|
/**
|
|
* Get the array representation of the notification.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'production_order',
|
|
'action' => 'created',
|
|
'production_order_id' => $this->productionOrder->id,
|
|
'code' => $this->productionOrder->code,
|
|
'creator_name' => $this->creatorName,
|
|
'message' => "{$this->creatorName} 建立了新的生產工單:{$this->productionOrder->code}",
|
|
'link' => route('production-orders.index', ['search' => $this->productionOrder->code]),
|
|
];
|
|
}
|
|
}
|