Implement basic logging #62
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\AuditLogEntry;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class LogViewer extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the incoming request.
|
||||||
|
*/
|
||||||
|
public function __invoke(Request $request)
|
||||||
|
{
|
||||||
|
$log_entries = AuditLogEntry::orderBy('created_at', 'desc')->paginate(20);
|
||||||
|
|
||||||
|
return view('admin.logview', compact('log_entries'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,4 +12,11 @@ class AuditLogEntry extends Model
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
protected $casts = ['affected' => 'json'];
|
protected $casts = ['affected' => 'json'];
|
||||||
|
|
||||||
|
public function getCreatedAtAttribute($value)
|
||||||
|
{
|
||||||
|
return \Carbon\Carbon::parse($value)
|
||||||
|
->setTimezone('America/Chicago')
|
||||||
|
->format('M j, Y H:i:s');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<x-layout.app>
|
||||||
|
<x-slot:page_title>AuditionAdmin Logs</x-slot:page_title>
|
||||||
|
<x-card.card>
|
||||||
|
<div class="px-4 sm:px-6 lg:px-8">
|
||||||
|
<div class="mt-4 flow-root">
|
||||||
|
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||||
|
<div class="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8">
|
||||||
|
<table class="min-w-full divide-y divide-gray-300">
|
||||||
|
<thead>
|
||||||
|
<tr class="divide-x divide-gray-200">
|
||||||
|
<th scope="col"
|
||||||
|
class="py-3.5 pl-4 pr-4 text-left text-sm font-semibold text-gray-900 sm:pl-0">
|
||||||
|
Timestamp
|
||||||
|
</th>
|
||||||
|
<th scope="col" class="px-4 py-3.5 text-left text-sm font-semibold text-gray-900">User
|
||||||
|
</th>
|
||||||
|
<th scope="col" class="px-4 py-3.5 text-left text-sm font-semibold text-gray-900">IP
|
||||||
|
</th>
|
||||||
|
<th scope="col"
|
||||||
|
class="py-3.5 pl-4 pr-4 text-left text-sm font-semibold text-gray-900 sm:pr-0">
|
||||||
|
Message
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-200 bg-white">
|
||||||
|
@foreach($log_entries as $entry)
|
||||||
|
@php($message = strip_tags($entry->message, '<br>'))
|
||||||
|
<tr class="divide-x divide-gray-200">
|
||||||
|
<td class="whitespace-nowrap py-4 pl-4 pr-4 text-sm font-medium text-gray-900 sm:pl-0">{{ $entry->created_at }}</td>
|
||||||
|
<td class="whitespace-nowrap p-4 text-sm text-gray-500">{{ $entry->user }}</td>
|
||||||
|
<td class="whitespace-nowrap p-4 text-sm text-gray-500">{{ $entry->ip_address }}</td>
|
||||||
|
<td class="whitespace-nowrap py-4 pl-4 pr-4 text-sm text-gray-500 sm:pr-0">{!! $message !!}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
|
||||||
|
<!-- More people... -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div class="py-6 border-t">
|
||||||
|
{{ $log_entries->links() }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</x-card.card>
|
||||||
|
|
||||||
|
</x-layout.app>
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
<a href="/admin/schools" class="block p-2 hover:text-indigo-600">Schools</a>
|
<a href="/admin/schools" class="block p-2 hover:text-indigo-600">Schools</a>
|
||||||
<a href="/admin/students" class="block p-2 hover:text-indigo-600">Students</a>
|
<a href="/admin/students" class="block p-2 hover:text-indigo-600">Students</a>
|
||||||
<a href="/admin/entries" class="block p-2 hover:text-indigo-600">Entries</a>
|
<a href="/admin/entries" class="block p-2 hover:text-indigo-600">Entries</a>
|
||||||
|
<a href="{{route('admin.view_logs')}}" class="block p-2 hover:text-indigo-600">View Logs</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->group(function () {
|
Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->group(function () {
|
||||||
Route::view('/', 'admin.dashboard')->name('admin.dashboard');
|
Route::view('/', 'admin.dashboard')->name('admin.dashboard');
|
||||||
|
Route::get('/logs', App\Http\Controllers\Admin\LogViewer::class)->name('admin.view_logs');
|
||||||
|
|
||||||
Route::post('/auditions/roomUpdate', [
|
Route::post('/auditions/roomUpdate', [
|
||||||
AuditionController::class, 'roomUpdate',
|
AuditionController::class, 'roomUpdate',
|
||||||
|
|
@ -31,8 +32,7 @@ Route::middleware(['auth', 'verified', CheckIfAdmin::class])->prefix('admin/')->
|
||||||
[AuditionSettings::class, 'save'])->name('audition-settings-save');
|
[AuditionSettings::class, 'save'])->name('audition-settings-save');
|
||||||
|
|
||||||
// Admin Bonus Scores Routes
|
// Admin Bonus Scores Routes
|
||||||
Route::prefix('bonus-scores')->controller(BonusScoreDefinitionController::class)->group(function (
|
Route::prefix('bonus-scores')->controller(BonusScoreDefinitionController::class)->group(function () {
|
||||||
) {
|
|
||||||
Route::get('/', 'index')->name('admin.bonus-scores.index');
|
Route::get('/', 'index')->name('admin.bonus-scores.index');
|
||||||
Route::post('/', 'store')->name('admin.bonus-scores.store');
|
Route::post('/', 'store')->name('admin.bonus-scores.store');
|
||||||
Route::post('/assign_auditions', 'assignAuditions')->name('admin.bonus-scores.addAuditions');
|
Route::post('/assign_auditions', 'assignAuditions')->name('admin.bonus-scores.addAuditions');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue