改进 工单回复以及邮件通知

This commit is contained in:
iVampireSP.com 2023-01-10 22:47:53 +08:00
parent dd49c870f6
commit ae4233bb39
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 14 additions and 8 deletions

View File

@ -25,7 +25,7 @@ public function store(Request $request, WorkOrder $work_order): RedirectResponse
'content' => 'required|string',
]);
if (!$work_order->isOpen()) {
if ($work_order->isFailure()) {
return back()->with('error', '工单还未就绪。');
}

View File

@ -9,6 +9,7 @@
use App\Models\User;
use App\Notifications\WorkOrder as WorkOrderNotification;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
@ -83,13 +84,6 @@ protected static function boot()
});
}
public function routeNotificationForMail(WorkOrderNotification $work_order): array
{
$user = $work_order->user;
return [$user->email => $user->name];
}
public function scopeThisModule($query)
{
return $query->where('module_id', auth('module')->id());
@ -148,4 +142,16 @@ public function safeDelete(): bool
return true;
}
public function routeNotificationForMail(WorkOrderNotification $work_order): array
{
$user = $this->user;
return [$user->email => $user->name];
}
public function receivesBroadcastNotificationsOn(): string
{
return new PrivateChannel('users.' . $this->id);
}
}