当前位置: 首页>>代码示例>>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;未经允许,请勿转载。