Updated ERP with new modules and features

This commit is contained in:
Kwesi Banson
2026-09-22 08:06:31 +00:00
parent 71bc103fee
commit 5174e82e51
53 changed files with 3706 additions and 203 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers;
use App\Models\ActivityLog;
use Illuminate\Http\Request;
class ActivityLogController extends Controller
{
public function index(Request $request)
{
$query = ActivityLog::with(['user', 'loggable'])->latest();
// 1. Filter by Action
if ($request->filled('action_type')) {
$query->where('action', $request->action_type);
}
// 2. Filter by Date Range
if ($request->filled('date_from')) {
$query->whereDate('created_at', '>=', $request->date_from);
}
if ($request->filled('date_to')) {
$query->whereDate('created_at', '<=', $request->date_to);
}
// 3. Search by User or Entity Type
if ($request->filled('search')) {
$searchTerm = $request->search;
$query->where(function ($q) use ($searchTerm) {
$q->whereHas('user', function ($userQuery) use ($searchTerm) {
$userQuery->where('name', 'like', '%' . $searchTerm . '%');
})
->orWhere('loggable_type', 'like', '%' . $searchTerm . '%');
});
}
$logs = $query->paginate(20)->withQueryString();
return view('activity-logs.index', compact('logs'));
}
}