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


PHP Message::orderBy方法代码示例

本文整理汇总了PHP中app\Message::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::orderBy方法的具体用法?PHP Message::orderBy怎么用?PHP Message::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Message的用法示例。


在下文中一共展示了Message::orderBy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $messages = Message::orderBy('created_at', 'desc')->get();
     if (count($messages) > 0) {
         return response()->json($messages);
     }
     abort(204);
 }
开发者ID:blrik,项目名称:CRUD-Vue-JS,代码行数:8,代码来源:ApiMessageController.php

示例2: Home

 public function Home(Request $request)
 {
     $page = (int) ($request->get('p', '1') > 0 ? $request->get('p', '1') : 1);
     $isPageMax = false;
     $messages = Message::orderBy('id', 'desc')->skip(($page - 1) * 10)->take(10)->get();
     if (count($messages) == 0 && $page > 1) {
         $pagemax = ceil(Message::count() / 10);
         return Redirect::route('adminMinichat', array('p' => $pagemax));
     }
     $nextMessages = Message::orderBy('id', 'desc')->skip($page * 10)->take(1)->get();
     if (count($nextMessages) == 0) {
         $isPageMax = true;
     }
     return view('admin.minichat.home', compact('page', 'isPageMax', 'messages'));
 }
开发者ID:kbiyo,项目名称:ARTTv2,代码行数:15,代码来源:MinichatController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $messages = null;
     if (!$request->has('accepted')) {
         $messages = Message::orderBy('created_at', 'desc')->simplePaginate(20);
     } else {
         if ($request->get('accepted') > 0) {
             $messages = Message::where('accepted', 1)->orderBy('created_at', 'desc')->simplePaginate(20);
             $messages->appends(['accepted' => 1]);
         } else {
             if ($request->get('accepted') <= 0) {
                 $messages = Message::where('accepted', 0)->orderBy('created_at', 'desc')->simplePaginate(20);
                 $messages->appends(['accepted' => 0]);
             } else {
                 $messages = Message::orderBy('created_at', 'desc')->simplePaginate(20);
             }
         }
     }
     $total = Message::count();
     $total_approved = Message::where('accepted', 1)->count();
     return response()->json(['data' => $messages->toArray(), 'total_count' => $total, 'approved_count' => $total_approved]);
 }
开发者ID:aninditkarmakar,项目名称:salmu-desi,代码行数:27,代码来源:MessageController.php

示例4: GetLastMessages

 public function GetLastMessages($nb = -1, $idPrevious = 0)
 {
     if ($nb <= 0) {
         if ($idPrevious > 0) {
             $messages = Message::where('id', '<', $idPrevious)->orderBy('id', 'desc')->get();
         } else {
             $messages = Message::orderBy('id', 'desc')->get();
         }
     } else {
         if ($idPrevious > 0) {
             $messages = Message::where('id', '<', $idPrevious)->orderBy('id', 'desc')->take($nb)->get();
         } else {
             $messages = Message::orderBy('id', 'desc')->take($nb)->get();
         }
     }
     $last = true;
     if (count($messages) > 0) {
         $lol = $messages[count($messages) - 1];
         if (Message::where('id', '<', $lol->id)->count() > 0) {
             $last = false;
         }
     }
     return view('front.minichat.messages', array('messages' => $messages, 'isLast' => $last));
 }
开发者ID:kbiyo,项目名称:ARTTv2,代码行数:24,代码来源:MinichatController.php

示例5: index

 /**
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\View\View
  */
 public function index(Request $request)
 {
     //获取最新的留言   数量?   排序?
     $messages = Message::orderBy('updated_at', 'desc')->paginate(false);
     return view('welcome', compact('authed', 'userInfo', 'messages'));
 }
开发者ID:pnagaraju25,项目名称:laravel5-example-1,代码行数:11,代码来源:WelcomeController.php

示例6: listMessages

 public function listMessages(Message $message)
 {
     return response()->json($message->orderBy("created_at", "DESC")->take(5)->get());
 }
开发者ID:huseyinbabal,项目名称:RealtimeChatLaravel,代码行数:4,代码来源:ChatController.php

示例7: index

 /**
  * Display a listing of the messages.
  *
  * @return Response
  */
 public function index(FormBuilder $formBuilder)
 {
     $form = $formBuilder->create('App\\Forms\\Herpakken', ['method' => 'POST', 'url' => route('verzenden')]);
     $messages = Message::orderBy('created_at', 'DESC')->paginate(20);
     return view('home', compact('form'))->with('messages', $messages);
 }
开发者ID:janhenckens,项目名称:herpakken,代码行数:11,代码来源:MessageController.php

示例8: messages

 public function messages()
 {
     $messages = Message::orderBy('created_at', 'desc')->paginate(15);
     return view('admin.messages', compact('messages'));
 }
开发者ID:omasterdesign,项目名称:omasterdefault,代码行数:5,代码来源:AdminController.php

示例9: scopeAllMessages

 public function scopeAllMessages()
 {
     $messages = Message::orderBy('created_at', 'desc')->paginate(10);
     return $messages;
 }
开发者ID:shine1rainbow,项目名称:blog,代码行数:5,代码来源:Message.php


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