label('Tolak') ->icon(Heroicon::OutlinedXMark) ->color('danger') ->schema([ Textarea::make('reason') ->label('Alasan Penolakan') ->placeholder('Jelaskan alasan pengajuan ditolak...') ->required(), ]) ->modalHeading(fn () => CheerfulNotification::getByKey('cooperation.reject_report_title')) ->modalDescription(fn () => CheerfulNotification::getByKey('cooperation.reject_proposal_desc')) ->action(function (Report $record, array $data): void { $record->update([ 'status' => ApprovalStatus::REJECTED, ]); $record->rejectionReasons()->create(['reason' => $data['reason']]); CheerfulNotification::warning( CheerfulNotification::getByKey('cooperation.report_rejected'), CheerfulNotification::getByKey('notification.report_rejected_notice', ['record__title' => $record->title]) )->send(); $partnerUser = $record->mediaTaskAssignment?->partnerMedia?->company?->user; if ($partnerUser) { $partnerUser->notify(new BroadcastNotification([ 'title' => CheerfulNotification::getByKey('cooperation.report_cooperation_rejected'), 'body' => CheerfulNotification::getByKey('notification.report_rejected_reason', ['record__title' => $record->title, 'record__mediaTaskAssignment__taskAssignment__cooperation__title' => $record->mediaTaskAssignment->taskAssignment->cooperation->title, 'data__reason' => $data['reason']]), 'action' => [ Action::make('view') ->label('Lihat') ->url(CooperationResource::getUrl('view', ['record' => $record->mediaTaskAssignment->taskAssignment->cooperation_id])), ], ])); } }) ->visible( fn (Report $record): bool => $record->mediaTaskAssignment?->taskAssignment?->cooperation?->status === CooperationStatus::VERIFICATION && ! auth()->user()->hasRole(RoleEnum::PERUSAHAAN->value) && $record->status === ApprovalStatus::PENDING ) ->modalWidth(Width::Large); } }