> $payload */ public function handle(array $payload): Subactivity { $subactivity = Subactivity::create(Arr::except($payload, 'activities')); $subactivity->activities()->sync($payload['activities']); return $subactivity; } /** * @return array */ public function rules(): array { return [ 'name' => 'required|unique:subactivities,name', 'activities' => 'present|array|min:1', 'is_filterable' => 'present|boolean', ]; } /** * @return array */ public function getValidationAttributes(): array { return [ 'activities' => 'Tätigkeiten', ]; } public function asController(ActionRequest $request): JsonResponse { return response()->json($this->handle($request->validated())); } }