$input * * @return Collection */ public function handle(array $input): Collection { return Nami::login((int) $input['mglnr'], $input['password'])->searchLayerOptions( SearchLayer::from($input['layer'] ?: 0), $input['parent'] ?: null ); } /** * @return array */ public function rules(): array { return [ 'mglnr' => 'required|numeric|min:0', 'password' => 'required|string', 'parent' => 'present', 'layer' => 'required|numeric', ]; } public function asController(ActionRequest $request): JsonResponse { $response = $this->handle($request->validated()); return response()->json($response); } }