Exemplo n.º 1
0
 public function index(Request $request, State $state)
 {
     $states = $state->orderBy('id', 'desc');
     if ($request->has('city_id')) {
         $states->where('city_id', $request->input('city_id'));
     }
     $states = $states->get();
     return $states;
 }
Exemplo n.º 2
0
 public function index(Request $request)
 {
     $states = State::orderBy('name', 'asc')->selectRaw('id as value, name as text')->where('city_id', $request->input('city_id'))->get()->toArray();
     return response()->json($states, 200, [], JSON_NUMERIC_CHECK);
 }