Exemple #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $regions = Region::all();
     $countries = Country::orderBy('name', 'asc')->get();
     $offers_air = Offer_air::orderBy('offerId', 'asc')->get();
     return view('cms/tags/create')->with('regions', $regions)->with('countries', $countries)->with('offers_air', $offers_air);
 }
 public function query($query)
 {
     $query = strtolower(filter_var($query, FILTER_SANITIZE_STRING));
     $cities_raw = Gulliver::getCitiesBooking();
     $cities = array();
     if (!Gulliver::$error) {
         foreach ($cities_raw as $city) {
             $city_name = strtolower($city['name']);
             if (strstr($city_name, $query)) {
                 $country = Country::where('code', $city['country'])->first();
                 $city = array('value' => $city['name'] . ', ' . $country->name . ' (' . $city['country'] . ')');
                 $cities[] = $city;
             }
         }
     }
     return json_encode($cities);
 }
Exemple #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id_region
  * @return \Illuminate\Http\Response
  */
 public function destroy($id_region)
 {
     $region = Region::findOrFail($id_region);
     $region_name = $region->name;
     $region->delete();
     $region_countries = Country::where('id_region', $id_region)->get();
     foreach ($region_countries as $country) {
         $country->id_region = null;
         $country->save();
     }
     return redirect()->route('regions.index')->with('message_delete', 'Region ' . $region_name . ' has been successfully deleted');
 }