本文整理匯總了PHP中app\Message::latest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Message::latest方法的具體用法?PHP Message::latest怎麽用?PHP Message::latest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Message
的用法示例。
在下文中一共展示了Message::latest方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
public function index()
{
// return \Auth::user()->name;
//use scope visible to show visible only
$messages = Message::latest()->visible()->get();
return view('messages.index', compact('messages'));
}
示例2: getMessages
public function getMessages(Request $request)
{
$messages = Message::latest()->where(['type' => $request->get('type'), 'to_user' => \Auth::user()->id])->get();
foreach ($messages as &$message) {
$user = User::findOrFail($message->from_user);
$message['from_user_name'] = $user->name;
}
if ($messages) {
$this->setResult($messages);
$this->succeed(true);
} else {
$this->setResult('獲取數據失敗');
$this->fail(true);
}
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$num_per_page = env('num_per_page_admin');
$messages = Message::latest()->paginate($num_per_page);
return view('admin.messages.index', compact('messages'));
}
示例4: messages
public function messages()
{
$messages = Message::latest()->paginate(3);
return view('admin.messages', compact('messages'));
}
示例5: indexRefresh
/**
* refresh messages content
*
* return user name and messages data to indexRefresh.blade.php
*/
public function indexRefresh()
{
$name = \Auth::user();
$messages = Message::latest()->get();
return view('main.indexRefresh', compact('messages', 'name'));
}