A simple audit viewer viewer for the package owen-it/laravel-auditing.
Add Audit Viewer as a dependency using the composer CLI:
composer require seinoxygen/audit-viewer
php artisan vendor:publish --provider="SeinOxygen\AuditViewer\AuditViewerServiceProvider" --tag=config
php artisan vendor:publish --provider="SeinOxygen\AuditViewer\AuditViewerServiceProvider" --tag=views
php artisan vendor:publish --provider="SeinOxygen\AuditViewer\AuditViewerServiceProvider" --tag=view-components
php artisan vendor:publish --provider="SeinOxygen\AuditViewer\AuditViewerServiceProvider" --tag=translations
If using < Laravel 5.5, add the AuditViewerServiceProvider to the providers array
'providers' => [
...
SeinOxygen\AuditViewer\AuditViewerServiceProvider::class,
...
],
Using your-url.com/audit-viewer you can have access to all audits saved on your database.
In your controller you'll need to add the AuditViewContract and the trait HasAudits.
Also you'll need to return the auditable model in the function setModel().
<?php
namespace App\Http\Controllers;
use App\Models\Blog;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use SeinOxygen\AuditViewer\Contracts\AuditViewContract;
use SeinOxygen\AuditViewer\Http\Traits\HasAudits;
class BlogController extends Controller implements AuditViewContract
{
use HasAudits;
public function setModel()
{
return Blog::class;
}
}
The trait automatically will add a function called audit($id) to the controller and you'll need to add that route manually to access all models audit.
You'll need to add routes manually to your controllers.
<?php
use App\Http\Controllers\BlogController;
use Illuminate\Support\Facades\Route;
Route::get('/blog/{model}/audit', [BlogController::class, 'audit']);
The MIT License (MIT). Please see License File for more information.