feat: add pagination to absence list
This commit is contained in:
parent
4f824525cb
commit
be494b5f21
0
app/Exceptions/AbsenceNotActionableException.php
Normal file → Executable file
0
app/Exceptions/AbsenceNotActionableException.php
Normal file → Executable file
@ -49,7 +49,7 @@ class AbsenceController extends Controller
|
||||
$this->authorize('viewAny', Absence::class);
|
||||
|
||||
return view('dashboard.absences.index')
|
||||
->with('absences', Absence::all());
|
||||
->with('absences', Absence::paginate(6));
|
||||
}
|
||||
|
||||
|
||||
@ -63,8 +63,11 @@ class AbsenceController extends Controller
|
||||
{
|
||||
$this->authorize('viewOwn', Absence::class);
|
||||
|
||||
// We can't paginate on the relationship found on the user model
|
||||
$absences = Absence::where('requesterID', Auth::user()->id)->paginate(6);
|
||||
|
||||
return view('dashboard.absences.own')
|
||||
->with('absences', Auth::user()->absences);
|
||||
->with('absences', $absences);
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,9 @@
|
||||
|
||||
<div class="card-title"><h4 class="text-bold">{{__('Leave of absence requests')}}</h4></div>
|
||||
|
||||
<div class="card-tools">
|
||||
<a href="{{ route('absences.create') }}"><button class="btn btn-success btn-sm"><i class="fas fa-plus-circle"></i> New request</button></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@ -103,7 +106,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('absences.create') }}"><button class="btn btn-success btn-sm"><i class="fas fa-plus-circle"></i> New request</button></a>
|
||||
{{ $absences->links() }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
8
resources/views/dashboard/absences/own.blade.php
Normal file → Executable file
8
resources/views/dashboard/absences/own.blade.php
Normal file → Executable file
@ -39,6 +39,10 @@
|
||||
|
||||
<div class="card-title"><h4 class="text-bold">{{__('Leave of absence requests')}}</h4></div>
|
||||
|
||||
<div class="card-tools">
|
||||
<a href="{{ route('absences.create') }}"><button class="btn btn-success btn-sm"><i class="fas fa-plus-circle"></i> New request</button></a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@ -85,7 +89,7 @@
|
||||
@endswitch
|
||||
</td>
|
||||
<td>{{ $absence->created_at }}</td>
|
||||
<td><a href="{{ route('absences.show', ['absence' => $absence->id]) }}" class="btn btn-warning btn-sm"><i class="fas fa-search"></i> {{ __('Review') }}</a></td>
|
||||
<td><a href="{{ route('absences.show', ['absence' => $absence->id]) }}" class="btn btn-warning btn-sm"><i class="fas fa-search"></i> {{ __('View') }}</a></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@ -103,7 +107,7 @@
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('absences.create') }}"><button class="btn btn-success btn-sm"><i class="fas fa-plus-circle"></i> New request</button></a>
|
||||
{{ $absences->links() }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user