added badge at audit action

This commit is contained in:
Jagad R R
2025-01-01 17:20:37 +07:00
parent d4bbe3a602
commit b4b95d2d93
3 changed files with 21 additions and 7 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ use App\Models\AuditTrail;
class AuditTrailHelper class AuditTrailHelper
{ {
public static function AddAuditTrail($activity, $action) public static function AddAuditTrail($action, $activity)
{ {
$audit = new AuditTrail(); $audit = new AuditTrail();
$audit->user_id = Auth::user()->id; $audit->user_id = Auth::user()->id;
@@ -19,7 +19,7 @@ class AuditTrailHelper
$audit->save(); $audit->save();
} }
public static function AuthAttempt($activity, $action) public static function AuthAttempt($action, $activity)
{ {
$audit = new AuditTrail(); $audit = new AuditTrail();
$audit->ip_address = request()->ip(); $audit->ip_address = request()->ip();
@@ -124,7 +124,7 @@ class LoginController extends Controller
} }
// Log activity // Log activity
AuditTrailHelper::AuthAttempt('Logout', 'User (' . $user->email . ') Logged out from the System'); AuditTrailHelper::AuthAttempt('Logout', 'User (' . $user->username . ') Logged out from the System');
try { try {
// Logout from admin guard // Logout from admin guard
@@ -38,8 +38,8 @@
<tr> <tr>
<th width="5%">{{ __('User') }}</th> <th width="5%">{{ __('User') }}</th>
<th width="5%">{{ __('Ip Address') }}</th> <th width="5%">{{ __('Ip Address') }}</th>
<th width="15%">{{ __('Action') }}</th> <th width="5%">{{ __('Action') }}</th>
<th width="5%">{{ __('Activity') }}</th> <th width="15%">{{ __('Activity') }}</th>
<th width="5%">Browser</th> <th width="5%">Browser</th>
<th width="15%">User Agent</th> <th width="15%">User Agent</th>
</tr> </tr>
@@ -48,10 +48,24 @@
@foreach ($data as $item) @foreach ($data as $item)
<tr> <tr>
<td> <td>
{{ $item->user ? $item->user->name : preg_replace('/\).*$/', '', explode('(', $item->action)[1]) }} {{ $item->user ? $item->user->name : preg_replace('/\).*$/', '', explode('(', $item->activity)[1]) }}
</td> </td>
<td>{{ $item->ip_address }}</td> <td>{{ $item->ip_address }}</td>
<td>{{ $item->action }}</td> <td>
@php
$color = 'info';
if ($item->action == 'Create') {
$color = 'success';
} elseif ($item->action == 'Update') {
$color = 'warning';
} elseif ($item->action == 'Delete') {
$color = 'danger';
}
@endphp
<div class="badge badge-{{ $color }} text-white">
{{ $item->action }}
</div>
</td>
<td>{{ $item->activity }}</td> <td>{{ $item->activity }}</td>
<td>{{ $item->browser }}</td> <td>{{ $item->browser }}</td>
<td>{{ $item->user_agent }}</td> <td>{{ $item->user_agent }}</td>