stateRepo = $stateRepository; } /** * @param $state_code * * @return \Illuminate\Http\JsonResponse */ public function index($state_code) { $state = $this->stateRepo->findOneBy(compact('state_code')); $stateRepo = new StateRepository($state); $data = $stateRepo->listCities(); return response()->json(compact('data')); } }