feat: ✨ add user filter on activity log
This commit is contained in:
parent
35ece6ca82
commit
89d9cfcaaf
8 changed files with 54 additions and 12 deletions
|
|
@ -23,6 +23,12 @@ class ActivityLogController extends Controller
|
|||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query = ActivityLog::query()->with('user');
|
||||
|
||||
/** @var \App\Models\User|null $userModel */
|
||||
$userModel = $request->route()->parameter('user');
|
||||
if ($userModel) {
|
||||
$query->where('user_id', $userModel->getKey());
|
||||
}
|
||||
|
||||
/** @var string $search Search field */
|
||||
$search = $request->search;
|
||||
if ($search) {
|
||||
|
|
@ -43,7 +49,12 @@ class ActivityLogController extends Controller
|
|||
/** Custom pagination */
|
||||
$activitylogModels = $this->paginate($query);
|
||||
|
||||
return view('bo.pages.activity_logs.index', compact('activitylogModels', 'search', 'searchFields'));
|
||||
return view('bo.pages.activity_logs.index', compact(
|
||||
'activitylogModels',
|
||||
'search',
|
||||
'searchFields',
|
||||
'userModel'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,8 +36,7 @@ class UserFactory extends Factory
|
|||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
return $this->state(fn (array $attributes) => [
|
||||
return $this->state(fn () => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import {
|
|||
faChevronRight,
|
||||
faCircleExclamation,
|
||||
faCircleInfo,
|
||||
faClockRotateLeft,
|
||||
faCopy,
|
||||
faCrop,
|
||||
faEraser,
|
||||
|
|
@ -69,5 +70,6 @@ library.add(faPaintRoller);
|
|||
library.add(faXmark);
|
||||
library.add(faChevronLeft);
|
||||
library.add(faChevronRight);
|
||||
library.add(faClockRotateLeft);
|
||||
|
||||
dom.watch();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
@extends('bo.layout')
|
||||
@extends('bo.layout', ['brParam' => $userModel])
|
||||
|
||||
@section('title', Str::ucfirst(trans_choice('models.classes.activity_log', '*')))
|
||||
@section('description', __('Liste de tous les :model', ['model' => trans_choice('models.classes.activity_log', '*')]))
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
@include('modules.breadcrumbs.breadcrumb-body')
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $userModel])
|
||||
</div>
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="table-responsive mb-3">
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
@section('title', __('Édition d\'un :model', ['model' => __('models.classes.user')]))
|
||||
@section('description', __('Édition d\'un :model déjà existant', ['model' => __('models.classes.user')]))
|
||||
@section('breadcrumb',
|
||||
request()->route()->getName())
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
|
||||
|
|
@ -15,9 +14,18 @@
|
|||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $userModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.users.destroy', $userModel) }}" method="POST" novalidate>
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.users.destroy', $userModel) }}" method="POST"
|
||||
novalidate>
|
||||
@can('isConceptor')
|
||||
<a class="btn btn-info" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.activity_logs.user', ['user' => $userModel]) }}"
|
||||
title="{{ str(trans_choice('models.classes.activity_log', 1))->ucfirst() }}">
|
||||
<i class="fa-solid fa-clock-rotate-left"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('duplicate', $userModel)
|
||||
<a class="btn btn-secondary" data-bs-toggle="tooltip" href="{{ route('bo.users.duplicate', ['user' => $userModel]) }}"
|
||||
<a class="btn btn-secondary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.users.duplicate', ['user' => $userModel]) }}"
|
||||
title="{{ Str::ucfirst(__('crud.actions.duplicate')) }}">
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
</a>
|
||||
|
|
@ -29,7 +37,8 @@
|
|||
@can('delete', $userModel)
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button class="btn btn-danger" data-bs-toggle="tooltip" type="submit" title="{{ Str::ucfirst(__('crud.actions.delete')) }}">
|
||||
<button class="btn btn-danger" data-bs-toggle="tooltip" type="submit"
|
||||
title="{{ Str::ucfirst(__('crud.actions.delete')) }}">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
@endcan
|
||||
|
|
|
|||
|
|
@ -28,8 +28,15 @@
|
|||
</td>
|
||||
<td class="text-end align-middle">
|
||||
@canAny(['delete', 'duplicate', 'update'], $userModel)
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.users.destroy', $userModel) }}" method="POST"
|
||||
novalidate>
|
||||
<form class="btn-group confirmDeleteTS" action="{{ route('bo.users.destroy', $userModel) }}"
|
||||
method="POST" novalidate>
|
||||
@can('isConceptor')
|
||||
<a class="btn btn-sm btn-info" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.activity_logs.user', ['user' => $userModel]) }}"
|
||||
title="{{ str(trans_choice('models.classes.activity_log', 1))->ucfirst() }}">
|
||||
<i class="fa-solid fa-clock-rotate-left"></i>
|
||||
</a>
|
||||
@endcan
|
||||
@can('duplicate', $userModel)
|
||||
<a class="btn btn-sm btn-secondary" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.users.duplicate', ['user' => $userModel]) }}"
|
||||
|
|
|
|||
|
|
@ -34,6 +34,17 @@ Breadcrumbs::for('bo.activity_logs.index', function (Generator $trail) {
|
|||
route('bo.activity_logs.index', ['sort_col' => 'created_at', 'sort_way' => 'desc'])
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('bo.activity_logs.user', function (Generator $trail, User $userModel) {
|
||||
$trail->push(
|
||||
Str::ucfirst(sprintf(
|
||||
'%s (%s %s)',
|
||||
trans_choice('models.classes.activity_log', 1),
|
||||
$userModel->first_name,
|
||||
$userModel->last_name
|
||||
)),
|
||||
route('bo.activity_logs.index', ['sort_col' => 'created_at', 'sort_way' => 'desc'])
|
||||
);
|
||||
});
|
||||
Breadcrumbs::for('bo.activity_logs.show', function (Generator $trail, ActivityLog $activity_log) {
|
||||
$trail->parent('bo.activity_logs.index');
|
||||
$trail->push(Str::ucfirst(trans('crud.actions.view')), route('bo.activity_logs.show', $activity_log));
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ Route::prefix('bo')
|
|||
Route::middleware('can:isConceptor')->group(function () {
|
||||
// * ACTIVITY LOGS.
|
||||
Route::resource('activity_logs', ActivityLogController::class)->only(['index', 'show']);
|
||||
Route::get('/activity_logs/user/{user:id}', [ActivityLogController::class, 'index'])
|
||||
->name('activity_logs.user');
|
||||
});
|
||||
});
|
||||
// * Others routes
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue