ActivityWorkAuditFail.php
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Actions;
use App\Enums\ActivityWorkStatusEnum;
use App\Models\ActivityUser;
use App\Models\Views\ActivityWork;
use App\Notifications\ActivitySingerSubmitWorkRejectNotification;
use App\Notifications\ActivitySubmitWorkRejectNotification;
use Lorisleiva\Actions\Concerns\AsAction;
use Lorisleiva\Actions\Concerns\AsJob;
class ActivityWorkAuditFail
{
use AsAction, AsJob;
public function handle(ActivityWork $work): void
{
ActivityUser::query()->whereKey($work->getKey())->update(['status' => ActivityWorkStatusEnum::REJECT]);
$this->pushUserNotification($work);
$this->pushBusinessNotification($work);
}
/**
* @param \App\Models\Views\ActivityWork $work
* @return void
*/
private function pushUserNotification(ActivityWork $work): void
{
$work->user?->notify(new ActivitySubmitWorkRejectNotification($work));
}
/**
* @param \App\Models\Views\ActivityWork $work
* @return void
*/
private function pushBusinessNotification(ActivityWork $work): void
{
$work->business?->notify(new ActivitySingerSubmitWorkRejectNotification($work));
}
}