$payload */ public function handle(array $payload): Activity { $activity = Activity::create($payload); $activity->subactivities()->sync($payload['subactivities']); return $activity; } /** * @return array */ public function rules(): array { return [ 'name' => 'required|max:255', 'is_filterable' => 'present|boolean', 'subactivities' => 'present|array', 'subactivities.*' => 'integer', ]; } public function asController(ActionRequest $request): RedirectResponse { $this->handle($request->validated()); return redirect()->route('activity.index'); } }