authorize('view', $website); $goals = $website->goals()->latest()->get(); return view('goals.index', compact('website', 'goals')); } public function create(Website $website): View { $this->authorize('view', $website); return view('goals.create', compact('website')); } public function store(StoreGoalRequest $request, Website $website): RedirectResponse { $this->authorize('view', $website); $data = $request->validated(); $data['is_active'] = $request->boolean('is_active', true); $website->goals()->create($data); return redirect() ->route('goals.index', $website) ->with('success', 'Goal created successfully.'); } public function edit(Website $website, Goal $goal): View { $this->authorize('view', $website); abort_unless($goal->website_id === $website->id, 404); return view('goals.edit', compact('website', 'goal')); } public function update(UpdateGoalRequest $request, Website $website, Goal $goal): RedirectResponse { $this->authorize('view', $website); abort_unless($goal->website_id === $website->id, 404); $data = $request->validated(); $data['is_active'] = $request->boolean('is_active', true); $goal->update($data); return redirect() ->route('goals.index', $website) ->with('success', 'Goal updated successfully.'); } public function destroy(Website $website, Goal $goal): RedirectResponse { $this->authorize('view', $website); abort_unless($goal->website_id === $website->id, 404); $goal->delete(); return redirect() ->route('goals.index', $website) ->with('success', 'Goal deleted successfully.'); } }