Event::all(), ]); } /** * Show the form for creating a new resource. */ public function create(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return view('Staff.event.create'); } /** * Store a newly created resource in storage. */ public function store(StoreEventRequest $request): \Illuminate\Http\RedirectResponse { Event::create($request->validated()); return to_route('staff.events.index'); } /** * Show the form for editing the specified resource. */ public function edit(Event $event): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return view('Staff.event.edit', [ 'event' => $event->load('prizes'), ]); } /** * Update the specified resource in storage. */ public function update(UpdateEventRequest $request, Event $event): \Illuminate\Http\RedirectResponse { $event->update($request->validated()); return to_route('staff.events.index'); } /** * Remove the specified resource from storage. */ public function destroy(Event $event): \Illuminate\Http\RedirectResponse { if ($event->claimedPrizes()->exists()) { return to_route('staff.events.index') ->withErrors('Cannot delete event because users have claimed prizes. You can mark it as inactive instead.'); } $event->delete(); return to_route('staff.events.index'); } }