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


PHP City::save方法代碼示例

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


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

示例1: store

 /**
  * Store a city.
  *
  * @param  array  $inputs
  * @param  integer $user_id
  * @return boolean
  */
 public function store($inputs, $user_id)
 {
     $city = new City();
     $city->content = $inputs['content'];
     $city->user_id = $user_id;
     $city->save();
 }
開發者ID:purgesoftwares,項目名稱:bloodapp,代碼行數:14,代碼來源:CityRepository.php

示例2: bulk_city_prov

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function bulk_city_prov()
 {
     // Start Check Authorization
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 1 or $authRole == 3) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('dashboard');
     }
     // End Check Authorization
     $data = RajaOngkir::Provinsi()->all();
     $citdat = RajaOngkir::Kota()->all();
     foreach ($data as $dat) {
         $province = new Province();
         // save category data into database //
         $province->id = $dat['province_id'];
         $province->name = $dat['province'];
         $province->save();
     }
     foreach ($citdat as $cdat) {
         $city = new City();
         $city->id = $cdat['city_id'];
         $city->id_provinces = $cdat['province_id'];
         $city->name_provinces = $cdat['province'];
         $city->name = $cdat['city_name'];
         $city->postal_code = $cdat['postal_code'];
         $city->type = $cdat['type'];
         $city->save();
     }
     Alert::success('Success Import Provinces and Cities !')->persistent("Close");
     return redirect('province/list')->with('message', 'You just imported !');
 }
開發者ID:arisros,項目名稱:drope.mployee,代碼行數:40,代碼來源:ProvinceController.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(CityRequest $request)
 {
     /** save data from City form to database **/
     $model = new City();
     $model->name = $request->get('name');
     $model->status = $request->get('status');
     $model->save();
     return redirect('city');
 }
開發者ID:jeanyu,項目名稱:azredirentals,代碼行數:15,代碼來源:CityController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $data = new City();
     $data->name = $request->name;
     $data->description = $request->description;
     $data->save();
     Session::flash('message', 'City named "' . $request->name . '" was successfully created');
     return redirect('/city');
 }
開發者ID:NavarezCorp,項目名稱:prenda,代碼行數:16,代碼來源:CityController.php

示例6: findOrCreate

 public static function findOrCreate($data)
 {
     $city = self::where('name', $data['city'])->first();
     if (count($city) <= 0) {
         $city = new City();
         $city->name = $data['city'];
         $city->state_id = State::findOrCreate($data)->id;
         $city->save();
     }
     return $city;
 }
開發者ID:rodrigoueda,項目名稱:tcc-fruto-urbano,代碼行數:11,代碼來源:City.php

示例7: process

 public function process(Request $request)
 {
     $oValidator = Validator::make($request->all(), ['name' => 'required|unique:city|max:255']);
     if ($oValidator->fails()) {
         return redirect('city/add')->withErrors($oValidator)->withInput();
     }
     $oCity = new City();
     $oCity->name = $request->name;
     $oCity->save();
     $request->session()->flash('notify', ['type' => 'Success', 'text' => 'Данные успешно сохранены!']);
     return redirect('city');
 }
開發者ID:shkatovdm,項目名稱:phponline_laravel,代碼行數:12,代碼來源:CityController.php

示例8: run

 public function run()
 {
     DB::statement("TRUNCATE TABLE cities CASCADE");
     $reader = Reader::createFromPath(base_path() . '/database/municipios.csv');
     foreach ($reader as $index => $row) {
         if (isset($row[1]) and isset($row[2]) and isset($row[3])) {
             $name = ucfirst(mb_strtolower($row[3], 'UTF-8'));
             $city = new City(['name' => $name, 'state_id' => $row[1]]);
             $city->id = $row[2];
             $city->save();
         }
     }
 }
開發者ID:rogerapras,項目名稱:app_veiculos,代碼行數:13,代碼來源:CityTableSeeder.php

示例9: 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, ['city' => 'required|unique', 'country' => 'required|exists:cities,country_id']);
     $city = new City();
     $city->city = $request->city;
     $city->country_id = $request->country;
     $city->save();
     foreach ($request->language as $language_id) {
         $city->language()->attach($language_id);
     }
     $statusCode = 200;
     $response = ["success" => "City successfully created"];
     return response($response, $statusCode);
 }
開發者ID:mudragel,項目名稱:matematika-test.loc,代碼行數:21,代碼來源:CityController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $request->name = ucfirst(strtolower($request->name));
     $this->validate($request, ['name' => 'required||max:255', 'population' => 'required|numeric', 'founded' => 'required']);
     $year = substr($request->founded, 6);
     $month = substr($request->founded, 3, -5);
     $day = substr($request->founded, 0, -8);
     $city = new City();
     $city->name = $request->name;
     $city->population = $request->population;
     $city->founded = $year . "-" . $month . "-" . $day;
     $city->added_on = date('Y-m-d');
     $city->save();
     return Redirect::route('admin.cidades.index');
 }
開發者ID:EnriqueSampaio,項目名稱:dag-parser,代碼行數:21,代碼來源:CityController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(City $city, CityStoreRequest $request)
 {
     $city = new City();
     $city->name = $request->input('name');
     $city->slug = strtolower($request->input('slug'));
     $city->geom = $request->input('lon') . ' ' . $request->input('lat');
     $city->state_id = $request->input('state_id');
     $city->facebook_id = $request->input('facebook_id');
     if ($city->save()) {
         Notification::success('Cidade editada!');
         return redirect()->route('cities.index');
     }
     Notification::error('Ops, falhou ao editar cidade.');
     return back();
 }
開發者ID:aquiprefeito,項目名稱:aquiprefeito-admin,代碼行數:21,代碼來源:CitiesController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validation //
     $validation = Validator::make($request->all(), ['name' => 'required|unique:categories|max:255', 'id_provinces' => 'required']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     $cities = new City();
     // save category data into database //
     $cities->name = $request->input('name');
     $cities->id_provinces = $request->input('id_provinces');
     $cities->save();
     Alert::success('Success Create, ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('province/list')->with('message', 'You just uploaded !');
 }
開發者ID:arisros,項目名稱:drope.mployee,代碼行數:22,代碼來源:CityController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $resource = new Resource();
     $resource->wood = 1000;
     $resource->stone = 1000;
     $resource->gold = 1000;
     $resource->save();
     $population = new Population();
     $population->count = 1000;
     $population->save();
     $city = new City();
     $city->Name = $request->name;
     $city->player()->associate(Auth::user());
     $city->resource()->associate($resource);
     $city->save();
 }
開發者ID:PetrKonecny,項目名稱:web_game,代碼行數:21,代碼來源:CityController.php

示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $lwd = new App\City();
     $lwd->name = 'Leeuwarden';
     $lwd->address = 'Wilhelmina Plein, 1234AX';
     $lwd->openingDay = 5;
     $lwd->openingHoursFrom = '07:00:00';
     $lwd->openingHoursTill = '17:00:00';
     $lwd->save();
     $groningen = new App\City();
     $groningen->name = 'Groningen';
     $groningen->address = 'Vismarkt, 9711 JB';
     $groningen->openingDay = 3;
     $groningen->openingHoursFrom = '07:00:00';
     $groningen->openingHoursTill = '17:00:00';
     $groningen->save();
 }
開發者ID:sanderdekroon,項目名稱:yourfoodbox,代碼行數:22,代碼來源:CitiesTableSeeder.php

示例15: bulk_city_prov

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function bulk_city_prov()
 {
     $data = RajaOngkir::Provinsi()->all();
     $citdat = RajaOngkir::Kota()->all();
     foreach ($data as $dat) {
         $province = new Province();
         // save category data into database //
         $province->id = $dat['province_id'];
         $province->name = $dat['province'];
         $province->save();
     }
     foreach ($citdat as $cdat) {
         $city = new City();
         $city->id = $cdat['city_id'];
         $city->id_provinces = $cdat['province_id'];
         $city->name_provinces = $cdat['province'];
         $city->name = $cdat['city_name'];
         $city->postal_code = $cdat['postal_code'];
         $city->type = $cdat['type'];
         $city->save();
     }
     Alert::success('Success Import Provinces and Cities !')->persistent("Close");
     return redirect('province/list')->with('message', 'You just imported !');
 }
開發者ID:arisros,項目名稱:drope.mployee,代碼行數:29,代碼來源:ProvinceController.php


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