當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。