except('withShow')); $userFilter = (new User())->searchFilter($queryParams); if($request->withShow) $userFilter = $userFilter->with('showDjs'); return response()->json($userFilter->get()); } /** * @throws \Exception */ public function store(Request $request) { try { $showInfos = $request->show; $showDaysRules = $request->showDaysRules; $showDjs = $request->showDjs; $show = Show::firstOrCreate($showInfos); $this->manageShowDays($show, $showDaysRules); $this->manageShowDjs($showDjs, $show); }catch(Exception $e){ return response()->json(['message' => $e->getMessage()], 500); } return response()->json(['message' => 'Show created successfully']); } public function show(ShowResource $show) { return new ShowResource($show); } public function update(ShowRequest $request, Show $show) { $show->update($request->validated()); return new ShowResource($show); } public function destroy(Request $request) { try { $showIds = $request->input('showIds'); Show::destroy($showIds); $responseMessage = 'Shows deleted'; } catch (Exception $e) { return response()->json(['message' => $e->getMessage()], 500); } return response()->json(['message' => $responseMessage]); } public function testSchedule(int $showId) { $show = Show::find($showId); $this->manageShowSchedule($show); } }