###diaries.controller index部分
public function index()
{
$data = [];
if (\Auth::check()) {
$user = \Auth::user();
$diaries = $user->diaries()->orderBy('created_at', 'desc')->paginate(25);
return view('diaries.index', [
'diaries' => $diaries,
]);
$data = [
'user' => $user,
'diaries' => $diaries,
];
}
return view('welcome', $data);
}
index.blade.php部分
{{ $messages->links('pagination::bootstrap-4') }}
{!! link_to_route('messages.create', '新規投稿', [], ['class' => 'btn btn-primary']) !!}