with(['owner:id,name,email', 'projectCollaborators']) ->select([ 'id', 'uuid', 'title', 'owner_user_id', 'transcription_status', 'transcription_engine', 'file_size', 'duration_seconds', 'language', 'created_at', 'deleted_at', // Sengaja TIDAK ambil: transcript_text, stored_audio_path ]) ->when($request->status, fn ($q, $s) => $q->where('transcription_status', $s)) ->when($request->search, fn ($q, $s) => $q->where('title', 'like', "%{$s}%") ) ->when($request->owner_id, fn ($q, $id) => $q->where('owner_user_id', $id)) ->orderByDesc('created_at') ->paginate(25) ->withQueryString(); $owners = User::where('role', 'user') ->where('is_active', true) ->orderBy('name') ->get(['id', 'name']); return view('admin.projects.index', compact('projects', 'owners')); } public function transferOwner( TransferOwnershipRequest $request, TranscriptionProject $project, TransferOwnershipAction $action ): RedirectResponse { $this->authorize('transferOwner', $project); $newOwner = User::findOrFail($request->new_owner_id); // Pastikan pemilik baru adalah pengguna aktif (bukan admin) abort_if($newOwner->isAdmin(), 403, 'Admin tidak boleh menjadi pemilik projek.'); abort_if(! $newOwner->isActive(), 422, 'Pengguna tidak aktif tidak boleh menerima pemindahan projek.'); abort_if($project->owner_user_id === $newOwner->id, 422, 'Projek sudah dimiliki oleh pengguna ini.'); $action->execute($project, $newOwner, $request->justification); return redirect()->route('admin.projects.index') ->with('success', "Pemilikan projek \"{$project->title}\" berjaya dipindahkan kepada {$newOwner->name}."); } }