So I have a problem, it's hard to explain but can be described as follows:
this is ouput if i paginate 10
The image above, I paginate 10, can be seen from the following code:
$list = Anime::where('status', 1)->paginate(10);
and if the image above, I paginate 5, it can be seen from the following code:
$list = Anime::where('status', 1)->paginate(5);
The following code image is displayed (blade file):
<div class="flex-shrink-0 h-10 w-10">
@if ($creator[$i]->profile_photo_path)
@php
$isi = $creator[$i]->profile_photo_path;
@endphp
<img class="h-10 w-10 rounded-full" src='' alt="">
@elseif ($creator[$i]->profile_photo_path == null || !$creator[$i]->profile_photo_path)
<img class="h-10 w-10 rounded-full" src="" alt="">
@endif
</div>
The following is the full content of the blade file:
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
</h2>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="flex flex-col">
<div class="-my-2 overflow-x-hidden sm:-mx-6 lg:-mx-8">
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="hidden md:inline-block px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Username
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Title
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Genre
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Rating
</th>
<th scope="col" class="relative px-6 py-3">
<span class="sr-only">Edit</span>
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach ($list as $i => $l)
<tr>
<td class="hidden md:inline-block px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10">
@if ($creator[$i]->profile_photo_path)
@php
$isi = $creator[$i]->profile_photo_path;
@endphp
<img class="h-10 w-10 rounded-full" src='' alt="">
@elseif ($creator[$i]->profile_photo_path == null || !$creator[$i]->profile_photo_path)
<img class="h-10 w-10 rounded-full" src="" alt="">
@endif
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900">
</div>
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900"></div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
@php $g = explode(',', $l->genre) @endphp
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<i class="fal fa-stars"></i>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<a href="" class="text-indigo-600 hover:text-indigo-900">Detail</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
<span>
</span>
</div>
</div>
Here's the controller method index:
public function index()
{
$list = Anime::where('status', 1)->paginate(5);
$creator = Anime::join('users', 'users.email', '=', 'animes.email')
->where('status', 1)
->get('users.profile_photo_path');
return view('anime.publicList', compact('list', 'creator'));
}
The problem is if I paginate it to 5 then when on the 2nd page the user image turns into an admin image (unlike the first image which paginated 10)
Aucun commentaire:
Enregistrer un commentaire