/** * 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(); }
/** * 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 !'); }
/** * 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!'); }
/** * 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'); }
/** * 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'); }
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; }
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'); }
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(); } } }
/** * 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); }
/** * 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'); }
/** * 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(); }
/** * 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 !'); }
/** * 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(); }
/** * 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(); }
/** * 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 !'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['name' => 'required', 'iata' => 'required', 'twitter_consumer_key' => 'required', 'twitter_consumer_secret' => 'required', 'twitter_access_token' => 'required', 'twitter_access_token_secret' => 'required']); $city = new City(Input::all()); $city->iata = substr(strtolower($city->iata), 0, 3); $city->user_id = $request->user()->id; $city->hidden = 1; $city->save(); return redirect('/')->with('message', $city->name . ' successfully created!'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // 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 // 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 !'); }
public function parseAndSave($html, $hhId, $link = null) { if (!$html) { return 'Parse error'; } $vacancy = new Vacancy(); if ($vacancy->where('hh_id', '=', $hhId)->first()) { return 'Vacancy ' . $hhId . ' found in database'; } //name if ($obj = $html->find('.b-vacancy-title', 0)) { $title = $obj->plaintext; } //description if ($obj = $html->find('.b-vacancy-desc-wrapper', 0)) { $description = $obj->innertext; } //address if ($obj = $html->find('.vacancy-address-text', 0)) { $address = $obj->innertext; } //company_name if ($obj = $html->find('.companyname', 0)) { $companyName = $obj->plaintext; } //employmentMode $employmentMode = array(); foreach ($html->find('.b-vacancy-employmentmode span') as $span) { $employmentMode[] = $span->innertext; } $head = $html->find('.b-vacancy-info .l-content-3colums', 0)->innertext; if ($res = $html->str_get_html($head)) { //content if ($obj = $res->find('.l-content-colum-1', 1)) { if ($tag = $obj->find('.l-paddings meta', 0)) { $currency = $tag->content; } } //salary if ($obj = $res->find('.l-content-colum-1', 1)) { if ($tag = $obj->find('.l-paddings', 0)) { $salaryText = $tag->plaintext; } } if (!empty($salaryText)) { if (!preg_match('/[\\d]{1}/i', $salaryText)) { $salary_from = 0; $salary_to = 0; } else { $salary = explode('до', $salaryText); if (isset($salary[0]) && strlen(trim($salary[0])) > 0) { preg_match_all('/[\\w]{2}(.*)[\\w\\s\\.]{1,4}/', $salary[0], $matches); $str = str_replace(chr(194) . chr(160), '', $matches[0][0]); $str = str_replace(' ', '', $str); $salary_from = intval($str); } if (isset($salary[1]) && strlen(trim($salary[1])) > 0) { preg_match_all('/[\\w\\s]{1,2}(.*)[\\w\\s]{1,3}/', $salary[1], $matches); $str = str_replace(chr(194) . chr(160), '', $matches[0][0]); $str = str_replace(' ', '', $str); $salary_to = intval($str); } } } //cityName if ($obj = $res->find('.l-content-colum-2', 1)) { if ($tag = $obj->find('.l-paddings', 0)) { $cityName = $tag->plaintext; } } //metro if ($obj = $res->find('.l-content-colum-2', 1)) { if ($tag = $obj->find('.metro-station', 0)) { $metro = $tag->plaintext; } } if (isset($metro)) { $cityName = str_replace(',', '', $cityName); $cityName = str_replace(',', '', $metro); $cityName = trim($cityName); } //experience if ($obj = $res->find('.l-content-colum-3', 1)) { if ($tag = $obj->find('.l-paddings', 0)) { $experience = $tag->plaintext; } } } // Save Vacancy $vacancy = new Vacancy(); if (isset($title)) { $vacancy->name = $title; } if (isset($companyName)) { $vacancy->company_name = $companyName; } if (isset($hhId)) { $vacancy->hh_id = $hhId; } if (isset($link)) { $vacancy->hh_link = $link; } if (isset($salary_from)) { $vacancy->salary_from = $salary_from; } if (isset($salary_to)) { $vacancy->salary_to = $salary_to; } if (isset($currency)) { $vacancy->currency = $currency; } if (isset($cityName)) { $cities = new City(); if ($city = $cities->where('name', '=', $cityName)->first()) { $vacancy->city_id = $city->id; } else { // save new city $city = new City(); $city->name = $cityName; $city->save(); $vacancy->city_id = $city->id; } } if (isset($experience)) { $vacancy->experience = $experience; } if (isset($description)) { $vacancy->description = $description; } if (isset($address)) { $vacancy->address = $address; } // save if (!$vacancy->save()) { return 'Vacancy not saved'; } // Employment Types Save if (count($employmentMode) > 0) { $empType = new \App\EmploymentType(); foreach ($employmentMode as $emp) { if ($find = $empType->where('name', 'LIKE', '%' . $emp . '%')->first()) { $empIds[] = $find->id; } else { // save new EmploymentType $employ = new EmploymentType(); $employ->name = $emp; $employ->save(); $empIds[] = $employ->id; } } $empType = new \App\EmploymentType(); $vacancy->employmentTypes()->attach($empIds); } return true; }