本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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'));
}
示例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;
}
示例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>";
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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) . "}";
}
示例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);
}
示例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);
}
}
示例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;
}
示例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]);
}
示例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}");
}