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


PHP Event::orderBy方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:HenOltma,项目名称:EventMap,代码行数:42,代码来源:EventController.php

示例2: getEvents

 public function getEvents()
 {
     return Event::orderBy('begin')->get(array('title', 'description', 'begin', 'end'));
 }
开发者ID:BoilerMake,项目名称:backend,代码行数:4,代码来源:GeneralController.php

示例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');
});
开发者ID:HackTheBook,项目名称:DigitalHeritageGeeks,代码行数:27,代码来源:routes.php


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