First public release. - docs: document the audit log, user offboarding, CSV export and the "require a reason for destructive actions" setting across README, docs/ and CLAUDE/AGENTS.md; note retention for panel_audit - docs: fill the publishing placeholders (repo URL, security contact, issue-template links) and add a semantic-versioning policy - move agent/contributor context into CLAUDE/ (AGENTS.md + a README); root CLAUDE.md is now a thin @-import pointer - add a favicon (shield-lock, matching the login screen) to the login page and the app layout - CHANGELOG: promote [Unreleased] to [1.0.0]; keep the earlier internal build as [0.1.0] Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UfuvfwexztdS7LDpGuKsuK
47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\AuditLog;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class AuditController extends Controller
|
|
{
|
|
/**
|
|
* Dziennik zmian panelu z filtrami (administrator / akcja / obiekt / okres).
|
|
*/
|
|
public function index(Request $request): View
|
|
{
|
|
$actor = trim((string) $request->query('actor', ''));
|
|
$action = trim((string) $request->query('action', ''));
|
|
$q = trim((string) $request->query('q', ''));
|
|
$from = $request->date('from');
|
|
$to = $request->date('to');
|
|
$perPage = max(10, min(200, (int) $request->query('per_page', 25)));
|
|
|
|
$entries = AuditLog::query()
|
|
->when($actor !== '', fn ($b) => $b->where('actor', 'like', "%{$actor}%"))
|
|
->when($action !== '', fn ($b) => $b->where('action', $action))
|
|
->when($q !== '', fn ($b) => $b->where(function ($b) use ($q) {
|
|
$b->where('target', 'like', "%{$q}%")->orWhere('target_dn', 'like', "%{$q}%");
|
|
}))
|
|
->when($from, fn ($b) => $b->where('created_at', '>=', $from->startOfDay()))
|
|
->when($to, fn ($b) => $b->where('created_at', '<=', $to->endOfDay()))
|
|
->orderByDesc('created_at')
|
|
->orderByDesc('id')
|
|
->paginate($perPage)
|
|
->withQueryString();
|
|
|
|
return view('admin.audit.index', [
|
|
'entries' => $entries,
|
|
'actions' => AuditLog::query()->select('action')->distinct()->orderBy('action')->pluck('action'),
|
|
'filters' => compact('actor', 'action', 'q') + [
|
|
'from' => $request->query('from'),
|
|
'to' => $request->query('to'),
|
|
],
|
|
]);
|
|
}
|
|
}
|