seinoxygen / audit-viewer
A simple audit viewer viewer for the package owen-it/laravel-auditing.
Installs: 103
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
Requires
- php: ^7.1|^8.0
- laravel/framework: ^7.0|^8.0|^9.0|^10.0
README
A simple audit viewer viewer for the package owen-it/laravel-auditing.
Installation
Add Audit Viewer as a dependency using the composer CLI:
composer require seinoxygen/audit-viewer
Publishing Assets
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
Basic Usage
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.
Controllers
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.
Routing
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']);
License
The MIT License (MIT). Please see License File for more information.