当前位置: 首页>>代码示例>>PHP>>正文


PHP City::where方法代码示例

本文整理汇总了PHP中app\City::where方法的典型用法代码示例。如果您正苦于以下问题:PHP City::where方法的具体用法?PHP City::where怎么用?PHP City::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\City的用法示例。


在下文中一共展示了City::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getlist

 public function getlist(Request $request)
 {
     $data = [];
     $data += ["" => '-- Selecciona ciudad --'];
     $data += City::where('state_id', $request->city_id)->lists('name', 'id')->toArray();
     return $data;
 }
开发者ID:etciberoamerica,项目名称:robotica,代码行数:7,代码来源:CityController.php

示例2: 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);
     }
 }
开发者ID:RestaurantListings,项目名称:restaurant_listings,代码行数:34,代码来源:WelcomeController.php

示例3: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param array $data
  *
  * @return User
  */
 protected function create(array $data)
 {
     $token = Token::where('token', '=', $data['registration_token'])->first();
     $city = City::where('id', '=', $token->city_id)->first();
     $user = User::create(['name_first' => $data['name_first'], 'name_last' => $data['name_last'], 'username' => $data['username'], 'bio' => $data['bio'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'city_id' => $city->id]);
     Event::fire(new PostSuccessfullAuth($data['registration_token']));
     return $user;
 }
开发者ID:EMT,项目名称:see-do,代码行数:15,代码来源:AuthController.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if ($this->user) {
         $cities = City::all();
     } else {
         $cities = City::where('hidden', '!=', 1)->get();
     }
     return view('home.index', compact('cities'));
 }
开发者ID:EMT,项目名称:see-do,代码行数:14,代码来源:CitiesController.php

示例5: 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;
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:19,代码来源:SiteRepository.php

示例6: city

 public static function city($id)
 {
     $id = unserialize($id);
     foreach ($id as $id) {
         $db_city = City::where('id', $id)->get();
         foreach ($db_city as $db) {
             echo $db->name . "<br>";
         }
     }
 }
开发者ID:arisros,项目名称:drope.mployee,代码行数:10,代码来源:Employee.php

示例7: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Get all the event records.
     $city = City::where('iata', '=', 'mcr')->first();
     $events = Event::get();
     // Get all the current events and attribute them to manchester (MCR).
     foreach ($events as $event) {
         $event->city_id = $city->id;
         $event->save();
     }
 }
开发者ID:EMT,项目名称:see-do,代码行数:16,代码来源:2016_02_16_111307_attribute_all_events_to_mcr.php

示例8: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Get all the user records.
     $city = City::where('iata', '=', 'mcr')->first();
     $users = User::get();
     // Get all the current users and associate them with manchester (MCR).
     foreach ($users as $user) {
         $user->city_id = $city->id;
         $user->save();
     }
 }
开发者ID:EMT,项目名称:see-do,代码行数:16,代码来源:2016_05_18_144546_associate_current_users_with_mcr.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $json_data = file_get_contents('custom/toronto_pois.json');
     $json_data = json_decode($json_data, false);
     foreach ($json_data as $poi) {
         if ($poi->lat == null) {
             continue;
         }
         $poi_obj = new \App\PointOfInterest();
         $poi_obj->name = $poi->name;
         $poi_obj->description = "";
         $poi_obj->lat = $poi->lat;
         $poi_obj->long = $poi->long;
         $city = \App\City::where('name', 'Toronto')->first();
         $all_districts = \App\District::where('city_id', $city->id)->get();
         $one_district = $all_districts[rand(0, count($all_districts) - 1)];
         $poi_obj->district_id = $one_district->id;
         $poi_obj->save();
     }
     $json_data = file_get_contents('custom/nyc_pois.json');
     $json_data = json_decode($json_data, false);
     foreach ($json_data as $poi) {
         $poi_obj = new \App\PointOfInterest();
         $poi_obj->name = $poi->name;
         $poi_obj->description = "";
         if ($poi->lat == null) {
             continue;
         }
         $poi_obj->lat = $poi->lat;
         $poi_obj->long = $poi->long;
         $city = \App\City::where('name', 'New York City')->first();
         $all_districts = \App\District::where('city_id', $city->id)->get();
         $one_district = $all_districts[rand(0, count($all_districts) - 1)];
         $poi_obj->district_id = $one_district->id;
         $poi_obj->save();
     }
     $json_data = file_get_contents('custom/paris_pois.json');
     $json_data = json_decode($json_data, false);
     foreach ($json_data as $poi) {
         $poi_obj = new \App\PointOfInterest();
         $poi_obj->name = $poi->name;
         $poi_obj->description = "";
         if ($poi->lat == null) {
             continue;
         }
         $poi_obj->lat = $poi->lat;
         $poi_obj->long = $poi->long;
         $city = \App\City::where('name', 'Paris')->first();
         $all_districts = \App\District::where('city_id', $city->id)->get();
         $one_district = $all_districts[rand(0, count($all_districts) - 1)];
         $poi_obj->district_id = $one_district->id;
         $poi_obj->save();
     }
 }
开发者ID:benpbrown,项目名称:cmpe332-site,代码行数:59,代码来源:PointsOfInterestTableSeeder.php

示例10: city1_autocomplete

 public function city1_autocomplete(Request $request)
 {
     $data = City::where('PolpulatedPlace', 'LIKE', $request->term . '%')->take(20)->get();
     // dd($data);
     // $results = [];
     foreach ($data as $key => $value) {
         // $results[] = ['id'=>$value->ID, 'oblast'=>$value->Region, 'obshtina'=>$value->Municipality, 'text'=>$value->PolpulatedPlace];
         // dd($results);
         $results[$key]['id'] = $value->ID;
         $results[$key]['text'] = $value->PolpulatedPlace;
     }
     return response()->json($results);
     //return "{ \"results\": " . json_encode($city) . "}";
 }
开发者ID:vasil1960,项目名称:gps,代码行数:14,代码来源:AutocompleteController.php

示例11: tweet

 private function tweet($event)
 {
     // Add check to see if the city has consumer secret/keys set, if not then add warning with url for city settings page.
     $city = City::where('id', '=', $event->city_id)->first();
     $title = $event->title;
     $date = date('d/m/y', strtotime($event->time_start));
     $time = date('g.ia', strtotime($event->time_start));
     $venue = explode(",", $event->venue)[0];
     $link = route('{city}.events.show', ['city' => $city->iata, 'slug' => $event->slug]);
     $status = $title . ' - ' . $date . ' - ' . $time . ' at ' . $venue . '. ' . $link;
     Twitter::reconfig(['consumer_key' => $city->twitter_consumer_key, 'consumer_secret' => $city->twitter_consumer_secret, 'token' => $city->twitter_access_token, 'secret' => $city->twitter_access_token_secret]);
     Twitter::postTweet(array('status' => $status, 'format' => 'json'));
     Log::info($status);
 }
开发者ID:EMT,项目名称:see-do,代码行数:14,代码来源:TweetSender.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $route = $request->path();
     if (Auth::user()) {
         $cities = City::all();
     } else {
         $cities = City::where('hidden', '!=', 1)->get();
     }
     if (count($cities) < 2 && $route == '/') {
         return redirect('/mcr');
     } else {
         return $next($request);
     }
 }
开发者ID:EMT,项目名称:see-do,代码行数:21,代码来源:RedirectIfOnlyCity.php

示例13: getTowns

 public function getTowns()
 {
     $input = \Request::all();
     $search = '%' . $input['term'] . '%';
     $cities = City::where('location', 'like', $search)->orderBy('location', 'asc')->take(10)->get()->lists('full_location', 'id');
     foreach ($cities as $key => $val) {
         $new_row['label'] = htmlentities(stripslashes($val));
         $new_row['value'] = htmlentities(stripslashes($val));
         $new_row['id'] = $key;
         $row_set[] = $new_row;
         //build an array
     }
     return $row_set;
 }
开发者ID:nelundeniya,项目名称:beauty,代码行数:14,代码来源:CitiesController.php

示例14: detectUserLocation

 public static function detectUserLocation()
 {
     $city = [NULL];
     if (auth()->check()) {
         $user = auth()->user();
         // $city = $user->profile->city()->get();
     } else {
         $user_location = GeoIP::getLocation();
         $city = City::where('slug', $user_location['city'])->get();
     }
     if (empty($city[0])) {
         $city[0] = City::first();
     }
     view()->share('user_city', $city[0]);
 }
开发者ID:vizovteam,项目名称:vizov,代码行数:15,代码来源:User.php

示例15: addFoodToArmy

 public function addFoodToArmy(Request $request, $city_id)
 {
     $city = City::where('id', $city_id)->first();
     if (!$this->validateOwner($city)) {
         return redirect('/home')->withErrors('Nem a te városod');
     }
     $food = $request->input("army_food");
     if (!$city->resources->food >= $food) {
         return redirect("/city/{$city_id}")->withErrors('Nincs elég élelmiszer');
     }
     $army = $city->army();
     $army->food += $food;
     $army->save();
     $city->resources->food -= $food;
     $city->resources->save();
     return redirect("/city/{$city_id}");
 }
开发者ID:nadapapa,项目名称:PHP-RTS-game,代码行数:17,代码来源:CityController.php


注:本文中的app\City::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。