feat: restrict report submission to accepted proposals owned by the authenticated user

This commit is contained in:
Yoga Pangestu 2026-04-10 13:22:17 +07:00
parent a03f3e3a7b
commit d39754ecfc

View File

@ -214,6 +214,10 @@ public function table(Table $table): Table
return $this->getOwnerRecord()->status === CooperationStatus::ASSIGNMENT
&& $taskAssignment->start_date->toDateString() <= now()->toDateString()
&& $taskAssignment->end_date->toDateString() >= now()->toDateString()
&& $this->getOwnerRecord()->proposal()
->whereHas('partnerMedia.company', fn ($q) => $q->where('user_id', auth()->id()))
->accepted()
->exists()
&& $taskAssignment->reports()
->whereHas('mediaTaskAssignment.partnerMedia.company', fn ($q) => $q->where('user_id', auth()->id()))
->where('reports.status', '!=', ApprovalStatus::REJECTED)