Index()

1public function index()
2{
3 $notices = Notice::with('user')->latest()->paginate(10);
4 
5 return view('notices.index', compact('notices'))
6 ->with('i', (request()->input('page', 1) - 1) * 10);
7}

View index

1@foreach($notices as $key => $notice)
2<tr class="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
3 <td class="py-4 px-6">
4 <a href="{{ route('notices.edit', $notice) }}">[수정]{{ route('notices.edit', $notice) }}</a>
5 </td>
6 <td scope="row" class="py-4 px-6 font-medium text-gray-900 whitespace-nowrap dark:text-white">
7 {{$key+1 +
8 (($notices->currentPage()-1) * 10)}}</td>
9 <td class="py-2 px-4">
10 <a class=" text-xl " href="{{ route('notices.show', $notice)}}">{{ route('notices.show',
11 $notice)}}{{$notice->subject}}</a>
12 </td>
13 <td>
14 <a href="mailto:{{$notice->email}}">{{$notice->user->name}}</a>
15 </td>
16</tr>
17@endforeach