First commit
This commit is contained in:
45
app/Http/Controllers/Admin/AuditLogController.php
Normal file
45
app/Http/Controllers/Admin/AuditLogController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\AuditLog;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AuditLogController extends Controller
|
||||
{
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$query = AuditLog::with('user')->latest('created_at');
|
||||
|
||||
if ($request->filled('event')) {
|
||||
$query->where('event', $request->event);
|
||||
}
|
||||
|
||||
if ($request->filled('user_id')) {
|
||||
$query->where('user_id', $request->user_id);
|
||||
}
|
||||
|
||||
if ($request->filled('date_from')) {
|
||||
$query->where('created_at', '>=', $request->date_from . ' 00:00:00');
|
||||
}
|
||||
|
||||
if ($request->filled('date_to')) {
|
||||
$query->where('created_at', '<=', $request->date_to . ' 23:59:59');
|
||||
}
|
||||
|
||||
$logs = $query->paginate(30)->withQueryString();
|
||||
|
||||
$eventTypes = AuditLog::distinct()->pluck('event')->sort()->values();
|
||||
|
||||
return view('admin.audit-logs.index', compact('logs', 'eventTypes'));
|
||||
}
|
||||
|
||||
public function show(AuditLog $auditLog): View
|
||||
{
|
||||
$auditLog->load('user');
|
||||
|
||||
return view('admin.audit-logs.show', compact('auditLog'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user