Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Added pagination when managing associated items to category
Browse files Browse the repository at this point in the history
Signed-off-by: WillTheDeveloper <willthedeveloper13@gmail.com>
  • Loading branch information
WillTheDeveloper committed Oct 15, 2022
1 parent b8d25c8 commit 81051f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 6 additions & 2 deletions app/Http/Controllers/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ public function create(Request $request)
return redirect(route('category.all'));
}

public function view($id) // Not sure why I have this, might delete later //
public function view($id)
{
return view('category', [
'data' => \App\Models\Category::query()->findOrFail($id)
'data' => \App\Models\Category::query()->findOrFail($id),
'inventory' => \App\Models\Inventory::query()
->where('category_id', $id)
->orderBy('name', 'asc')
->paginate(5)
]);
}

Expand Down
13 changes: 8 additions & 5 deletions resources/views/category.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,21 @@
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
@foreach($data->Inventory as $i)
@foreach($inventory as $i)
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6"><a href="{{route('inventory.manage-id', $i->id)}}">{{$i->name}}</a></td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{$i->quantity}}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{$i->description}}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{$i->collect_location}}</td>
<td class="py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6"><a href="{{route('inventory.manage-id', $i->id)}}">{{$i->name}}</a></td>
<td class="px-3 py-4 text-sm text-gray-500">{{$i->quantity}}</td>
<td class="px-3 py-4 text-sm text-gray-500">{{$i->description}}</td>
<td class="px-3 py-4 text-sm text-gray-500">{{$i->collect_location}}</td>
</tr>
@endforeach

<!-- More people... -->
</tbody>
</table>
<div class="px-2 py-2">
{{$inventory->links()}}
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 81051f8

Please sign in to comment.