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