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