本文整理汇总了PHP中app\City类的典型用法代码示例。如果您正苦于以下问题:PHP City类的具体用法?PHP City怎么用?PHP City使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了City类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 !');
}
示例2: 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!');
}
示例3: findByProvinceCity
/**
* Find a site based on province, city and slug input
*
* @param string $province
* @param string $city
* @param string $slug
*
* @return mixed
*/
public function findByProvinceCity($province, $city, $slug)
{
$p = new Province();
$province = $p->where('slug', $province)->first();
$c = new City();
$city = $c->where(['province_id' => $province->id, 'slug' => $city])->first();
$s = new Site();
$site = $s->where(['city_id' => $city->id, 'slug' => $slug])->first();
return $site;
}
示例4: 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;
}
示例5: 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();
}
}
}
示例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, ['city' => 'required', 'country' => 'required|exists:countries,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 {$request->city} successfully created"];
return response($response, $statusCode);
}
示例7: 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();
}
示例8: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$province_id = Input::get('province_id');
$city_id = Input::get('city_id');
$specialization_id = Input::get('specialization_id');
$verified = Input::get('verified');
$data = array();
if (empty($province_id) && empty($city_id) && empty($specialization_id) && empty($verified)) {
//menampilkan semua gender
$data['content'] = \App\Doctor::all();
$data['province_id'] = null;
$data['city_id'] = null;
$data['specialization_id'] = null;
$data['verified'] = null;
} else {
$data['content'] = $data['province_id'] = $province_id;
$data['city_id'] = $city_id;
$data['specialization_id'] = $specialization_id;
$data['verified'] = $verified;
}
$data['list_province'] = \App\Province::lists('name', 'id');
$data['list_city'] = \App\City::lists('name', 'id');
$data['list_specialization'] = \App\Specialization::lists('name', 'id');
return view('pages.admin.clinic.doctor.index')->with('data', $data);
}
示例9: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$brand = Brand::find($id);
$cities = City::lists('city_name', 'id')->all();
$brand_types = BrandType::lists('type_name', 'id')->all();
return view('admin.brands.edit', compact('brand', 'cities', 'brand_types'));
}
示例10: edit
/**
* Show the form for editing the specified resource.
*
* @param Venue $venue
* @return Response
* @internal param int $id
*/
public function edit(Venue $venue)
{
$features = Feature::lists('feature', 'id');
$cities = City::lists('name', 'id');
$types = Type::lists('type', 'id');
return view('venues.edit', compact('venue', 'features', 'cities', 'types'));
}
示例11: remove
public function remove(Request $request)
{
$oCity = City::find($request->id);
$oCity->delete();
$request->session()->flash('notify', ['type' => 'Success', 'text' => 'Данные успешно удалены!']);
return redirect('city');
}
示例12: processSiege
public static function processSiege(Army $army, City $city)
{
// TODO check if the army has catapult
// TODO message users about the result
$attack_point = $army->calculateAttackingPoints();
$defense_point = $city->calculateDefensePoints();
if ($attack_point > $defense_point) {
// attacker wins
// the city becomes the attacker's city
$city->update(['owner' => $army->user->id, 'capital' => 0, 'nation' => $army->user->nation]);
$city->hex->update(['owner' => $army->user->id]);
} elseif ($attack_point < $defense_point) {
// defender wins
$army->destroyArmy();
}
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
if ($request->file('image')) {
if ($request->file('image')->isValid()) {
$fileName = (int) round(microtime(true) * 1000);
$fileName .= '.' . $request->file('image')->guessExtension();
$path = public_path() . '/img/uploads/';
$request->file('image')->move($path, $fileName);
$image = $fileName;
}
} else {
$image = null;
}
$latitude = $request->input('latitude');
$longitude = $request->input('longitude');
$city = $request->input('city');
$state = $request->input('state');
$country = $request->input('country');
$city = City::findOrCreate(compact('city', 'state', 'country'))->id;
$point = new Spatialpoint();
$point->point = Spatialpoint::geom($latitude, $longitude);
$point->species = $request->input('species');
$point->comments = $request->input('comments');
$point->type = $request->input('type');
$point->address = $request->input('address');
$point->image = $image;
$point->user_id = Auth::user()->id;
$point->city_id = $city;
$point->save();
}
示例14: index
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
DB::connection()->enableQueryLog();
$data['location'] = GeoIP::getLocation();
$l_city = $data['location']['city'];
$l_state = $data['location']['state'];
$agent = new Agent();
$get_city = \App\City::where('city', '=', $l_city)->take(1)->get();
if (count($get_city) != 0) {
foreach ($get_city as $c) {
$city = $c->id;
}
} else {
$city = 894;
$data['location']['city'] = 'Phoenix';
$data['location']['state'] = 'AZ';
}
$data['recent_restaurants'] = \App\Restaurants::where('having_menu', '=', '1')->where('city_id', '=', $city)->orderBy(DB::raw('RAND()'))->take(4)->get();
$data['recent_reviews'] = \App\Restaurant_Reviews::orderBy(DB::raw('RAND()'))->leftJoin('restaurants', 'restaurants_reviews.restaurants_id', '=', 'restaurants.id')->leftJoin('city', 'restaurants.city_id', '=', 'city.id')->leftJoin('state', 'restaurants.state_id', '=', 'state.id')->take(6)->get();
//$data['nearest_zip'] = \App\Zip::where('zip', '>', (int)session('geoip-locations.postal_code')-10)->where('zip', '<', (int)session('geoip-locations.postal_code')+10)
// ->take(5)->get();
//dd(DB::getQueryLog());
//dd($data['recent_reviews']);
if ($agent->isMobile()) {
return view('mobile_home')->with($data);
} else {
return view('home')->with($data);
}
}
示例15: slugs
public function slugs()
{
$slugs = Slug::orderBy('updated_at', 'desc')->get();
/******************/
$dirtyCities = Flight::doesntHave('city')->orderBy('country_code')->groupBy('city')->get();
$cleanCities = City::groupBy('city_slug')->get();
$noMatches = array();
$dirtyCountries = array();
$cleanCountries = array();
foreach ($dirtyCities as $dirtyCity) {
$similarsArray = array();
foreach ($cleanCities as $cleanCity) {
similar_text($dirtyCity->city_slug, $cleanCity->city_slug, $percent);
$similarityArray[$cleanCity->city_slug] = $percent;
$cleanCountries[$cleanCity->city_slug] = $cleanCity->country_code;
}
//sort in descending order
arsort($similarityArray);
//take first few with highest similarity
$similarityArray = array_slice($similarityArray, 0, 8);
$noMatches[$dirtyCity->city_slug] = $similarityArray;
$dirtyCountries[$dirtyCity->city_slug] = $dirtyCity->country_code;
}
return view('scrapers.slugs')->with(['slugs' => $slugs, 'noMatches' => $noMatches, 'dirtyCountries' => $dirtyCountries, 'cleanCountries' => $cleanCountries]);
}