本文整理汇总了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);
}
示例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'));
}
示例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]);
}
示例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));
}
示例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'));
}
示例6: listMessages
public function listMessages(Message $message)
{
return response()->json($message->orderBy("created_at", "DESC")->take(5)->get());
}
示例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);
}
示例8: messages
public function messages()
{
$messages = Message::orderBy('created_at', 'desc')->paginate(15);
return view('admin.messages', compact('messages'));
}
示例9: scopeAllMessages
public function scopeAllMessages()
{
$messages = Message::orderBy('created_at', 'desc')->paginate(10);
return $messages;
}