本文整理汇总了PHP中app\City::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP City::orderBy方法的具体用法?PHP City::orderBy怎么用?PHP City::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\City
的用法示例。
在下文中一共展示了City::orderBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
$data = [];
$url['back_url'] = 'city';
$data['city'] = City::orderBy('created_at', 'DESC')->paginate(10);
return View('city/add', $data)->nest('panel', 'sections.panel', $url);
}
示例2: getSearch
public function getSearch()
{
// get all the cities from cities table in alphabetical order
$city = City::orderBy('name')->get();
//make the insert view with cities
return View::make('search')->with('cities', $city);
}
示例3: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$cities = City::orderBy('name')->get();
$selector = array();
foreach ($cities as $city) {
$selector[$city->id] = $city->name;
}
return view('admin.investiments', ['cities' => $selector]);
}
示例4: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$cities = City::orderBy('name')->get();
foreach ($cities as $city) {
$day = substr($city->founded, 8);
$month = substr($city->founded, 5, -3);
$year = substr($city->founded, 0, -6);
$city->founded = $day . "/" . $month . "/" . $year;
}
return view('admin.cities', ['cities' => $cities]);
}
示例5: getInsert
public function getInsert()
{
//Use to insert data to the cities table for time being
/*$city = new City;
$city->name = 'Colombo';
$city->save();*/
// get all the cities from cities table in alphabetical order
$city = City::orderBy('name')->get();
//make the insert view with cities
return View::make('insert')->with('cities', $city);
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$toronto_districts = array("Alexandra Park", "The Annex", "Baldwin Village", "Cabbagetown", "CityPlace", "Chinatown", "Church and Wellesley", "Corktown", "Discovery District", "Distillery District");
$paris_districts = array("Louvre", "Bourse", "Temple", "Hôtel-de-Ville", "Panthéon", "Luxembourg", "Palais-Bourbon", "Élysée", "Opéra");
$nyc_districts = array("Downtown Manhattan", "Little Germany (historic)", "Alphabet City and Loisaida", "East Village", "Greenwich Village", "NoHo", "Bowery", "West Village", "Lower East Side");
$cities = City::orderBy('id', 'asc')->get();
foreach ($cities as $city) {
if (strcmp("New York City", $city->name) == 0) {
foreach ($nyc_districts as $district) {
DB::table('districts')->insert(['name' => $district, 'description' => '', 'city_id' => $city->id]);
}
} elseif (strcmp("Toronto", $city->name) == 0) {
foreach ($toronto_districts as $district) {
DB::table('districts')->insert(['name' => $district, 'description' => '', 'city_id' => $city->id]);
}
} elseif (strcmp("Paris", $city->name) == 0) {
foreach ($paris_districts as $district) {
DB::table('districts')->insert(['name' => $district, 'description' => '', 'city_id' => $city->id]);
}
}
}
}
示例7: redirect
$data = $request->all();
$validator = Validator::make($request->all(), ['property_id' => 'required|numeric|integer|min:0']);
if ($validator->fails()) {
return redirect(url('/admin'))->withInput()->withErrors($validator);
}
$user = Property::find($data['property_id'])->delete();
return redirect(url('/admin'));
});
Route::delete('/property/photo/{picture}', function (Picture $picture) {
\Cloudinary\Uploader::destroy($picture->cloudinary_public_id);
$property_id = PropertyPictureBridge::where('picture_id', $picture->id)->get()[0]->property_id;
$picture->delete();
return redirect(url('/property/edit/photos/' . $property_id));
});
Route::get('/property/edit/{property_id}', function ($property_id) {
$cities = City::orderBy('name', 'asc')->get();
$property = Property::find($property_id);
$property->district_name = District::find($property->district_id)->name;
$property->city_name = City::find($property->city_id)->name;
$amenities = PropertyFeatures::where('property_id', $property->id)->get()[0];
return view('edit_property', ['property' => $property, 'cities' => $cities, 'amenities' => $amenities]);
});
Route::get('/property/edit/photos/{property_id}', function ($property_id) {
$property = Property::find($property_id);
$images = get_all_images_from_property_id_without_placeholder($property_id);
return view('edit_images', ['property' => $property, 'images' => $images]);
});
Route::post('/property/edit', function (Request $request) {
$data = $request->all();
$validator = Validator::make($request->all(), ['title' => 'required|max:255', 'city' => 'required', 'district' => 'required', 'address' => 'required|max:255', 'type' => 'required|in:private_room,shared_room,entire_place', 'max_occupancy' => 'required|numeric|min:0|integer', 'price_per_night' => 'required|numeric|min:0|max:9999.99', 'description' => 'required', 'property_id' => 'required|numeric|integer|min:0']);
if ($validator->fails()) {
示例8: cities
public function cities()
{
$cities = City::orderBy('city_name', 'asc')->get();
return view('scrapers.cities')->with(['cities' => $cities]);
}