コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function countries()
 {
     $results = \Excel::load('country_list.xlsx', function ($reader) {
     })->get();
     foreach ($results as $row) {
         $country = new Country();
         $country->country_code = $row->country_code;
         $country->country_name = $row->country_name;
         $country->country_name_in_albanian = $row->country_name_in_albanian;
         $country->country_name_in_czech = $row->country_name_in_czech;
         $country->country_name_in_dutch_belgium = $row->country_name_in_dutch_belgium;
         $country->country_name_in_finnish = $row->country_name_in_finnish;
         $country->country_name_in_greek = $row->country_name_in_greek;
         $country->country_name_in_hungarian = $row->country_name_in_hungarian;
         $country->country_name_in_kazakh = $row->country_name_in_kazakh;
         $country->country_name_in_macedonian = $row->country_name_in_macedonian;
         $country->country_name_in_polish = $row->country_name_in_polish;
         $country->country_name_in_portuguese = $row->country_name_in_portuguese;
         $country->country_name_in_romanian = $row->country_name_in_romanian;
         $country->country_name_in_russian = $row->country_name_in_russian;
         $country->country_name_in_slovak = $row->country_name_in_slovak;
         $country->country_name_in_spanish = $row->country_name_in_spanish;
         $country->country_name_in_turkish = $row->country_name_in_turkish;
         $country->continent = $row->continent;
         $country->iseurope = $row->iseurope;
         $country->save();
     }
 }
コード例 #2
0
 public function run()
 {
     DB::table('countries')->truncate();
     $country = new Country();
     $country->name = 'England';
     $country->country_code = 'EN';
     //        $language->icon = "icon_flag_gb.gif";
     $country->icon = "flag-en";
     $country->save();
     $country = new Country();
     $country->name = 'Ukraine';
     $country->country_code = 'UA';
     //        $language->icon = "icon_flag_sr.gif";
     $country->icon = "flag-ua";
     $country->save();
     $country = new Country();
     $country->name = 'Russia';
     $country->country_code = 'RU';
     //        $language->icon = "icon_flag_bs.gif";
     $country->icon = "flag-ru";
     $country->save();
     $country = new Country();
     $country->name = 'USA';
     $country->country_code = 'US';
     //        $language->icon = "icon_flag_bs.gif";
     $country->icon = "flag-us";
     $country->save();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Model::unguard();
     //create a user
     $user = new User();
     $user->email = "*****@*****.**";
     $user->password = Hash::make('password');
     $user->save();
     //create a country
     $country = new Country();
     $country->name = "United States";
     $country->id = 236;
     $country->save();
     //create a state
     $state = new State();
     $state->name = "Pennsylvania";
     $state->id = 1;
     $state->save();
     $city = new City();
     $city->name = "Pittsburgh";
     $city->id = 1;
     $city->save();
     //create a location
     $location = new Location();
     $location->city_id = $city->id;
     $location->state_id = $state->id;
     $location->country_id = $country->id;
     $location->latitude = 40.44;
     $location->longitude = 80;
     $location->code = '15212';
     $location->address_1 = "100 Main Street";
     $location->save();
     //create a new accommodation
     $accommodation = new Accommodation();
     $accommodation->name = "Royal Plaza Hotel";
     $accommodation->location_id = $location->id;
     // $location->id;
     $accommodation->description = "A modern, 4-star hotel";
     $accommodation->save();
     //create a room
     $room1 = new App\Room();
     $room1->id = 1;
     $room1->room_number = 'A01';
     $room1->accommodation_id = $accommodation->id;
     $room1->save();
     //create another room
     $room2 = new Room();
     $room2->id = 2;
     $room2->room_number = 'A02';
     $room2->accommodation_id = $accommodation->id;
     $room2->save();
     //create the room array
     $rooms = [$room1, $room2];
     //$this->call('AuthorsTableSeeder');
     //$this->command->info('Authors table seeded!');
     //
     $this->call(AmenityTableSeeder::class);
     $this->command->info('Amenity Class Seeded table seeded!');
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CountryRequest $request)
 {
     /** save data from Country form to database **/
     $model = new Country();
     $model->name = $request->get('name');
     $model->status = $request->get('status');
     $model->save();
     return redirect('country');
 }
コード例 #5
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('country')->truncate();
     $country_nz = ['name' => "New Zealand", 'meta_desc' => "New Zealand is an island country in the southern Pacific Ocean. The country comprises two main landmasses – the North Island, South Island, and others.", 'long_desc' => "New Zealand (Māori: Aotearoa) is an island country in the southwestern Pacific Ocean. The country geographically comprises two main landmasses – that of the North Island, or Te Ika-a-Māui, and the South Island, or Te Waipounamu – and numerous smaller islands. New Zealand is situated some 1,500 kilometres (900 mi) east of Australia across the Tasman Sea and roughly 1,000 kilometres (600 mi) south of the Pacific island areas of New Caledonia, Fiji, and Tonga. Because of its remoteness, it was one of the last lands to be settled by humans. During its long isolation, New Zealand developed a distinctive biodiversity of animal, fungal and plant life. The country's varied topography and its sharp mountain peaks, such as the Southern Alps, owe much to the tectonic uplift of land and volcanic eruptions. New Zealand's capital city is Wellington, while its most populous city is Auckland.", 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()];
     $country = new Country($country_nz);
     $country->save();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
コード例 #6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['country' => 'required|unique:countries']);
     $country = new Country();
     $country->country = $request->country;
     $country->save();
     $statusCode = 200;
     $response = ["success" => "Country {$country->country} successfully created"];
     return response($response, $statusCode);
 }
コード例 #7
0
 public static function findOrCreate($data)
 {
     $country = self::where('name', $data['country'])->first();
     if (count($country) <= 0) {
         $country = new Country();
         $country->name = $data['country'];
         $country->save();
     }
     return $country;
 }
コード例 #8
0
 public function postCountry(Request $request)
 {
     $name = $request['country_name'];
     $description = $request['country_description'];
     $status = true;
     $country = new Country();
     $country->name = $name;
     $country->description = $description;
     $country->status = $status;
     $country->save();
     return redirect()->route('country')->with(['message' => 'Successfully Saved!']);
 }
コード例 #9
0
 public function playerCountry(Request $request)
 {
     $this->validate($request, ['country_title' => 'required']);
     //dd($request->all());
     if ($request->file('ajax-country-flag')) {
         // $this->validate($request,['ajax-country-flag'=>'required|image|mimes:jpeg,jpg,png,bmp,gif,svg']);
         $file = $request->file('ajax-country-flag');
         $path = $this->_country_flag_path;
         $name = uniqid() . $file->getClientOriginalName();
         $file->move($path, $name);
     }
     $country = new Country(array('title' => $request->get('country_title'), 'flag_name' => $name, 'flag_path' => $path));
     $country->save();
     $countries = Country::all();
     return response()->json($countries);
 }
コード例 #10
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     if ($request['countryId'] != 0) {
         $retcountry = Country::whereId($request['countryId'])->first();
         if ($retcountry) {
             $country = Country::find($request['countryId']);
             $country->name = $request['name'];
             $country->save();
             Session::flash('message', 'Country Updated Successfully');
         }
     } else {
         $country = new Country();
         $country->name = $request['name'];
         $country->save();
         Session::flash('message', 'Country added Successfully');
     }
     return Redirect::to('country');
 }
コード例 #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate(CountryRequest $request)
 {
     $country = new Country();
     $country->country_code = $request->country_code;
     $country->name = $request->name;
     $icon = "";
     if (Input::hasFile('icon')) {
         $file = Input::file('icon');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $icon = sha1($filename . time()) . '.' . $extension;
     }
     $country->icon = $icon;
     $country->save();
     if (Input::hasFile('icon')) {
         $destinationPath = public_path() . '/images/country/' . $country->id . '/';
         Input::file('icon')->move($destinationPath, $icon);
     }
 }
 public function getUpdateinfo(Request $request)
 {
     $arr = $request->all();
     //把未赋值的参数赋为null
     while (list($key, $val) = each($arr)) {
         if ($val == "") {
             $arr[$key] = null;
         }
     }
     if ($request->has("country")) {
         //如果存在id,说明是更新信息
         if ($request->has("id") && $arr["id"]) {
             $country = Country::find($arr["id"]);
             $country->country = $arr["country"];
             $country->belongs = $arr["belongs"];
             $country->note = $arr["note"];
         } else {
             //说明是新增数据
             $country = new Country();
             $country->country = $arr["country"];
             $country->belongs = $arr["belongs"];
             $country->note = $arr["note"];
         }
         try {
             if ($country->save()) {
                 $response = array('status' => ['error' => 0, 'note' => '操作成功'], 'influence' => 1);
                 return json_encode($response);
             } else {
                 $response = array('status' => ['error' => 1, 'note' => '操作失败'], 'influence' => 0);
                 return json_encode($response);
             }
         } catch (QueryException $e) {
             $response = array('status' => ['error' => 2, 'note' => '操作失败'], 'influence' => 0);
             return json_encode($response);
         }
     } else {
         $response = array('status' => ['error' => -1, 'note' => '缺少参数country'], 'influence' => 0);
         return json_encode($response);
     }
 }
コード例 #13
0
	public function postCreateCountry(Request $request)
	{
		$arr_return = array();
		$country = new Country();
		$name = $request->has('name') ? $request->input('name') : '';
		$country->name = $name;
		if($country->save()){
			$arr_return['status'] = 'success';
		}else{
			$arr_return['message'] = 'Saving fail';
		}
		return $arr_return;
	}
コード例 #14
0
 public function ClearUpVariables($data, $hour_stamp)
 {
     //amend values as I wish
     $data['hour_stamp'] = $hour_stamp;
     $data['hour_stamp_flight_number'] = str_replace(' ', '', $hour_stamp . $data['flight_number']);
     //unique column
     $data['scheduled_time'] = Carbon::createFromFormat('d.m. H:i', $data['scheduled_time']);
     //airline code
     preg_match("|^..|", $data['flight_number'], $output_array_3);
     $data['airline_code'] = strtolower($output_array_3[0]);
     if ($data['airline_code'] == "ez") {
         $data['airline_code'] = "u2";
     }
     //easyjet not using their IATA code U2 but EZY - manual correction
     //terminal
     preg_match("|[1-9]|", $data['terminal'], $output_array_4);
     $data['terminal'] = $output_array_4[0];
     //destination
     $data['destination'] = strtolower($data['destination']);
     //keep all such data in lowercase (because Sqlite differentiate between Capitals and lower)
     preg_match("|(.*)\\((.*)\\)|", $data['destination'], $output_array_1);
     if (count($output_array_1) > 1) {
         $CitySlashAirport = $output_array_1[1];
         $data['country_code'] = $output_array_1[2];
     } else {
         $CitySlashAirport = null;
         $data['country_code'] = 'xx';
     }
     unset($data['destination']);
     //in case some strange codes comes
     $country = Country::where('country_code', $data['country_code']);
     if (count($country) == 0) {
         $newcountry = new Country();
         $newcountry->country_code = $data['country_code'];
         $newcountry->country_name = 'Undefined';
         $newcountry->save();
     }
     $output_array_2 = preg_split("|\\/|", $CitySlashAirport);
     $data['city'] = $output_array_2[0];
     if (empty($data['city'])) {
         $data['city'] = 'empty';
     }
     if (count($output_array_2) > 1) {
         $data['airport'] = $output_array_2[1];
     } else {
         $data['airport'] = null;
     }
     //city_slug
     $slug = new SlugClass();
     $data['city_slug'] = $slug->slugify($data['city']);
     //find if this city_slug is in cities table
     $city_slug_in_cities = City::where('city_slug', $data['city_slug'])->first();
     if (empty($city_slug_in_cities)) {
         $city_slug_bridge = Slug::where('city_slug_dirty', $data['city_slug'])->first();
         if (!empty($city_slug_bridge)) {
             $data['city_slug'] = $city_slug_bridge->city_slug_clean;
             echo $data['city_slug'];
         }
     }
     $data = array_map('trim', $data);
     //trim values
     return $data;
 }