當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Country::save方法代碼示例

本文整理匯總了PHP中app\Country::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Country::save方法的具體用法?PHP Country::save怎麽用?PHP Country::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Country的用法示例。


在下文中一共展示了Country::save方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: countries

 /**
  * 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();
     }
 }
開發者ID:kalyandey,項目名稱:livingadventure,代碼行數:33,代碼來源:ImportexcelController.php

示例2: run

 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();
 }
開發者ID:alex311982,項目名稱:laravel5_online_support,代碼行數:28,代碼來源:CountriesSeeder.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Model::unguard();
     //create a user
     $user = new User();
     $user->email = "hotel@test.com";
     $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!');
 }
開發者ID:piyushpk89,項目名稱:MasteringLaravelCode_by_Christopher_John,代碼行數:64,代碼來源:DatabaseSeeder.php

示例4: store

 /**
  * 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');
 }
開發者ID:jeanyu,項目名稱:azredirentals,代碼行數:15,代碼來源:CountryController.php

示例5: run

 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');
 }
開發者ID:rattfieldnz,項目名稱:jobs-aggregator,代碼行數:9,代碼來源:NewZealandCountry.php

示例6: store

 /**
  * 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);
 }
開發者ID:mudragel,項目名稱:matematika-test.loc,代碼行數:17,代碼來源:CountryController.php

示例7: findOrCreate

 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;
 }
開發者ID:rodrigoueda,項目名稱:tcc-fruto-urbano,代碼行數:10,代碼來源:Country.php

示例8: postCountry

 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!']);
 }
開發者ID:megmarcaida,項目名稱:smixs,代碼行數:12,代碼來源:CountryController.php

示例9: playerCountry

 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);
 }
開發者ID:leloulight,項目名稱:RealMadrid,代碼行數:16,代碼來源:CountriesController.php

示例10: create

 /**
  * 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');
 }
開發者ID:premsingh4github,項目名稱:recruitment,代碼行數:23,代碼來源:CountryController.php

示例11: postCreate

 /**
  * 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);
     }
 }
開發者ID:alex311982,項目名稱:laravel5_online_support,代碼行數:24,代碼來源:CountryController.php

示例12: getUpdateinfo

 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);
     }
 }
開發者ID:ChenPeiyuan,項目名稱:student-infomation-manager,代碼行數:40,代碼來源:CountryManageController.php

示例13: postCreateCountry

	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;
	}
開發者ID:kamitori,項目名稱:khuongnhi2,代碼行數:13,代碼來源:SettingsController.php

示例14: ClearUpVariables

 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;
 }
開發者ID:jedlicka82,項目名稱:pragueairport,代碼行數:63,代碼來源:PragueAirportScraper.php


注:本文中的app\Country::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。