本文整理汇总了PHP中app\City::all方法的典型用法代码示例。如果您正苦于以下问题:PHP City::all方法的具体用法?PHP City::all怎么用?PHP City::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\City
的用法示例。
在下文中一共展示了City::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($id)
{
$cities = City::all();
$categories = Category::all();
$post = $this->postRepository->getById($id);
return view('posts.edit', compact('post', 'cities', 'categories'));
}
示例2: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$communitys = Community::all();
$cities = City::all();
$categories = Category::all();
return view('posts.create', ['communitys' => $communitys, 'categories' => $categories, 'cities' => $cities]);
}
示例3: boot
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$pages = Page::all();
$cities = City::all();
view()->share('pages', $pages);
view()->share('cities', $cities);
}
示例4: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$cities = City::all();
// Grab all the cities and then do a for each.
// run this for each of them.
foreach ($cities as $city) {
$events = Event::where('city_id', '=', $city->id)->where('time_end', '>=', date('Y-m-d H:i:s'))->where('time_end', '<=', date('Y-m-d H:i:s', strtotime('+2 weeks')))->orderBy('time_start', 'asc')->get();
if (!count($events)) {
$this->comment('No events found for ' . $city->name . '. Mailer not sent.');
continue;
}
$categories = Category::orderBy('title', 'asc')->get();
if ($this->option('email')) {
$subscriber = new Subscriber();
$subscriber->name = 'Test User';
$subscriber->email = $this->option('email');
$subscribers = [$subscriber];
$this->comment('Sent test email to ' . $this->option('email'));
} else {
$subscribers = Subscriber::where('city_id', '=', $city->id)->get();
}
$count = 0;
foreach ($subscribers as $subscriber) {
Mail::send('emails.subscribers.mailer', ['subscriber' => $subscriber, 'events' => $events, 'categories' => $categories, 'city' => $city], function ($m) use($subscriber, $city) {
$m->from('messages@madebyfieldwork.com', 'See+Do')->to($subscriber->email, $subscriber->name)->subject('Weekly Round-Up of Things to See+Do in ' . $city->name)->getHeaders()->addTextHeader('X-MC-Subaccount', 'see-do');
});
$count++;
}
$this->comment('Sent to ' . $count . ' email addresses in ' . $city->name . '.');
$count = 0;
}
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$zone = Zone::findOrFail($id);
$page = "Editer " . $zone->name;
$cities = City::all();
return view('admin.zone.edit', compact('zone', 'page', 'cities'));
}
示例6: index
public function index()
{
$cities = City::all();
// $locations = Location::all();
// return view('worldmap.map')->with(compact('locations'));
return view('worldmap.worldmap')->with(compact('cities'));
}
示例7: index
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
$posts = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->orderBy('created_at', 'desc')->take(4)->get();
$mostPopular = Post::with('author', 'comments.author', 'community')->where('sold', NULL)->take(4)->get();
$communities = Community::all();
$cities = City::all();
return view('pages.home', ['posts' => $posts, 'mostPopular' => $mostPopular, 'communities' => $communities, 'cities' => $cities]);
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$allusers = User::all();
$url = "https://randomapi.com/api/?key=" . env('RANDOMAPI_API_KEY') . "&id=6tnf0qn&results=50";
$json = file_get_contents($url);
$json_data = json_decode($json, true);
$types = ['private_room', 'shared_room', 'entire_place'];
foreach ($json_data['results'] as $result) {
$result = $result['object'];
$property = new Property();
$property->title = $result['title'];
$oneuser = $allusers[rand(0, count($allusers) - 1)];
$property->owner_id = $oneuser->id;
$property->address = explode(" | ", $result['address'])[2];
$all_cities = City::all();
$property->city_id = $all_cities[rand(0, count($all_cities) - 1)]->id;
$valid_districts = District::where('city_id', $property->city_id)->get();
$property->district_id = $valid_districts[rand(0, count($valid_districts) - 1)]->id;
$property->type = $types[array_rand($types)];
$property->price_per_night = rand(20, 1333);
$property->max_occupancy = rand(1, 6);
$property->description = 'A charming ' . $result['title'];
$property->save();
$features = new PropertyFeatures();
$features->property_id = $property->id;
$features->kitchen = rand(0, 1) == 1;
$features->internet = rand(0, 1) == 1;
$features->tv = rand(0, 1) == 1;
$features->essentials = rand(0, 1) == 1;
$features->shampoo = rand(0, 1) == 1;
$features->heating = rand(0, 1) == 1;
$features->air_conditioning = rand(0, 1) == 1;
$features->washer = rand(0, 1) == 1;
$features->dryer = rand(0, 1) == 1;
$features->free_parking_on_premises = rand(0, 1) == 1;
$features->wireless_internet = rand(0, 1) == 1;
$features->cable_tv = rand(0, 1) == 1;
$features->breakfast = rand(0, 1) == 1;
$features->pets_allowed = rand(0, 1) == 1;
$features->family_kid_friendly = rand(0, 1) == 1;
$features->suitable_for_events = rand(0, 1) == 1;
$features->smoking_allowed = rand(0, 1) == 1;
$features->wheelchair_accessible = rand(0, 1) == 1;
$features->elevator_in_building = rand(0, 1) == 1;
$features->indoor_fireplace = rand(0, 1) == 1;
$features->buzzer_wireless_intercom = rand(0, 1) == 1;
$features->doorman = rand(0, 1) == 1;
$features->pool = rand(0, 1) == 1;
$features->hot_tub = rand(0, 1) == 1;
$features->gym = rand(0, 1) == 1;
$features->feature_24_hour_check_in = rand(0, 1) == 1;
$features->hangers = rand(0, 1) == 1;
$features->iron = rand(0, 1) == 1;
$features->hair_dryer = rand(0, 1) == 1;
$features->laptop_friendly_workspace = rand(0, 1) == 1;
$features->save();
}
}
示例9: 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'));
}
示例10: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$title = 'CONFIG';
$country = Country::all()->sortBy('country');
$designation = Designation::all()->sortBy('designation');
$city = City::all()->sortBy('city');
$state = State::all()->sortBy('state');
$brands = Brands::all()->sortBy('brand');
$models = Models::all()->sortBy('model');
$businessType = BusinessType::all()->sortBy('name');
return view('myConfig.index', compact('title', 'country', 'designation', 'city', 'state', 'brands', 'models', 'businessType'));
}
示例11: 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);
}
}
示例12: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if ($this->option('all')) {
foreach (City::all() as $city) {
$city->import();
sleep(5);
}
} elseif ($this->argument('city')) {
$city = City::find($this->argument('city'));
if (count($city)) {
$city->import();
}
}
}
示例13: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
Departure::truncate();
Line::truncate();
Stop::truncate();
$cities = City::all();
foreach ($cities as $city) {
$this->info('importing city: ' . $city->name);
$lines = Line::import($city);
foreach ($lines as $line) {
$this->info('importing line: ' . $line->name);
$stops = Stop::fullImport($line);
}
}
}
示例14: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create($company_id)
{
$company = Company::find($company_id);
$countries = Country::all();
foreach ($countries as $ctr) {
$country_names[$ctr->id] = $ctr->name;
}
$cities = City::all();
foreach ($cities as $ct) {
$city_names[$ct->id] = $ct->name;
}
foreach (Language::all() as $lang) {
$langs[$lang->id] = $lang->name;
}
return view('jobs.create', compact('country_names', 'city_names', 'langs', 'company'));
}
示例15: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
echo 'Warning: Running this migration is not completely backwards compatible and will make changes to event \'category_id\' references and category \'id\' references. Cancel out of this migration within the next 10 seconds if you dont have a backup...';
echo "\n";
sleep(15);
echo 'Continuing with migration...';
echo "\n";
Schema::table('categories', function (Blueprint $table) {
$table->integer('city_id');
});
$cities = City::all();
$categories = Category::all();
foreach ($cities as $city) {
Category::create(['title' => 'Talks', 'city_id' => $city->id]);
Category::create(['title' => 'Gigs', 'city_id' => $city->id]);
Category::create(['title' => 'Exhibitions', 'city_id' => $city->id]);
Category::create(['title' => 'Hackdays & Workshops', 'city_id' => $city->id]);
Category::create(['title' => 'Films', 'city_id' => $city->id]);
Category::create(['title' => 'Food & Drink', 'city_id' => $city->id]);
$city_events = Event::all();
foreach ($city_events as $event) {
if ($event->city_id == $city->id) {
// get the current category_id.
// get the category by that id.
$old_category = Category::where('id', $event->category_id)->first();
// get the name of the category.
// find the new category for this city with that name.
$new_category = Category::where('slug', $old_category->slug)->where('city_id', $city->id)->first();
// set the event to new category.
$event->category_id = $new_category->id;
$event->save();
}
}
}
$categories = Category::all();
foreach ($categories as $category) {
if ($category->city_id == 0) {
$category->delete();
}
}
}