本文整理汇总了PHP中app\models\Event::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::orderBy方法的具体用法?PHP Event::orderBy怎么用?PHP Event::orderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Event
的用法示例。
在下文中一共展示了Event::orderBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postIndex
public function postIndex()
{
$validator = Validator::make(Request::all(), Event::$optionRules);
if ($validator->passes()) {
// validation has passed, write events in range on that date to xml File
$geocoding_arr = Event::lookup(Request::input('adress'));
$events = Event::orderBy('updated_at', 'DESC')->get();
$date = strtotime(Request::input('date'));
//$range = Request::input('range');
(double) ($lat = $geocoding_arr['latitude']);
(double) ($lng = $geocoding_arr['longitude']);
//Start XML file, create parent node
$xml = new XMLWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');
//markers
$xml->startElement('markers');
foreach ($events as $event) {
$distance = 6371 * acos(cos(deg2rad($lat)) * cos(deg2rad($event->latitude)) * cos(deg2rad($event->longitude) - deg2rad($lng)) + sin(deg2rad($lat)) * sin(deg2rad($event->latitude)));
if ($distance <= $range) {
if (strtotime($event->Begin) <= $date && strtotime($event->End) >= $date) {
$xml->startElement('marker');
$xml->writeAttribute('name', $event->title);
$xml->writeAttribute('content', $event->content);
$xml->writeAttribute('type', $event->type);
$xml->writeAttribute('link', $event->link);
$xml->writeAttribute('longitude', $event->longitude);
$xml->writeAttribute('latitude', $event->latitude);
$xml->endElement();
}
}
}
//close markers
$xml->endElement();
//write to file
file_put_contents('markers.xml', $xml->outputMemory());
return view('events.index');
} else {
// validation has failed, display error messages
return redirect('events/index')->with('message', 'danger|Die folgenden Fehler sind aufgetreten:')->withErrors($validator)->withInput();
}
}
示例2: getEvents
public function getEvents()
{
return Event::orderBy('begin')->get(array('title', 'description', 'begin', 'end'));
}
示例3: function
<?php
/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('dashboard', function () {
$events = \App\Models\Event::orderBy('updated_at', 'desc')->take(4)->get();
$latest = \App\Models\Log::orderBy('updated_at', 'desc')->take(4)->get();
return view('dashboard', compact('events', 'latest'));
});
Route::controller('places', 'PlacesController');
Route::group(['middleware' => ['web'], 'prefix' => 'api'], function () {
//
});
Route::get('test', function () {
return view('tsipras');
});