user()->hasRole(RoleEnum::PERUSAHAAN->value)) { return $ownerRecord->cooperationMedia() ->whereHas('partnerMedia.company', function ($query) { $query->where('user_id', auth()->id()); }) ->accepted() ->exists(); } return true; } public function table(Table $table): Table { return $table ->columns([ ...RowIndexColumn::make(), TextColumn::make('start_date') ->label('Tanggal Mulai') ->date('l, d F Y'), TextColumn::make('end_date') ->label('Tanggal Selesai') ->date('l, d F Y'), TextColumn::make('task_description') ->label('Deskripsi Tugas') ->wrap() ->html(), TextColumn::make('report_amount') ->label('Jumlah Bukti Tayang'), ]) ->headerActions([ CreateAction::make() ->label('Buat Media Order') ->modalWidth('md') ->schema([ DatePicker::make('start_date') ->label('Tanggal Mulai') ->native(false) ->displayFormat('l, d F Y') ->required(), DatePicker::make('end_date') ->label('Tanggal Selesai') ->native(false) ->displayFormat('l, d F Y') ->required() ->afterOrEqual('start_date'), TextInput::make('report_amount') ->label('Jumlah Bukti Tayang') ->numeric() ->minValue(1) ->required() ->autocomplete(false), Textarea::make('task_description') ->label('Deskripsi Tugas') ->required() ->rows(4) ->placeholder('...') ->autocomplete(false), ]) ->visible(function (): bool { $user = auth()->user(); if (! $user->hasRole(RoleEnum::PERUSAHAAN->value)) { return false; } $cooperation = $this->getOwnerRecord(); $isPartner = $cooperation->cooperationMedia() ->whereHas('partnerMedia.company', function ($query) use ($user) { $query->where('user_id', $user->id); }) ->accepted() ->exists(); $hasAcceptedProposal = $cooperation->proposal()->accepted()->exists(); return $isPartner && $hasAcceptedProposal && $cooperation->status === CooperationStatus::ASSIGNMENT; }) ->successNotification( fn () => CheerfulNotification::success( CheerfulNotification::getByKey('cooperation.assignment_success'), CheerfulNotification::getByKey('cooperation.assignment_set_success') ) ), ]) ->recordActions([ EditAction::make() ->modalWidth('md') ->schema([ DatePicker::make('start_date') ->label('Tanggal Mulai') ->native(false) ->displayFormat('l, d F Y') ->required(), DatePicker::make('end_date') ->label('Tanggal Selesai') ->native(false) ->displayFormat('l, d F Y') ->required() ->afterOrEqual('start_date'), TextInput::make('report_amount') ->label('Jumlah Bukti Tayang') ->numeric() ->minValue(1) ->required() ->autocomplete(false), Textarea::make('task_description') ->label('Deskripsi Tugas') ->required() ->rows(4) ->placeholder('...') ->autocomplete(false), ]) ->successNotification( fn () => CheerfulNotification::success( CheerfulNotification::getByKey('cooperation.assignment_updated'), CheerfulNotification::getByKey('cooperation.assignment_updated_desc') ) ), DeleteAction::make() ->successNotification( fn () => CheerfulNotification::success( CheerfulNotification::getByKey('cooperation.assignment_deleted'), CheerfulNotification::getByKey('cooperation.assignment_deleted_desc') ) ), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make() ->successNotification( fn () => CheerfulNotification::success( CheerfulNotification::getByKey('cooperation.assignment_deleted_success'), CheerfulNotification::getByKey('cooperation.bulk_assignment_deleted') ) ), ]), ]) ->emptyStateIcon(Heroicon::OutlinedArchiveBoxXMark) ->emptyStateHeading(fn () => CheerfulNotification::getByKey('cooperation.assignment_empty_heading')) ->emptyStateDescription(fn () => CheerfulNotification::getByKey('cooperation.assignment_empty')); } }