-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start recording changes to storage box model
This will give us a history of previous owners of a storage box, which we can later build a UI for admins to see on site
- Loading branch information
Showing
6 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Implementation | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Define which Audit model implementation should be used. | ||
| | ||
*/ | ||
|
||
'implementation' => OwenIt\Auditing\Models\Audit::class, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| User Morph prefix & Guards | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Define the morph prefix and authentication guards for the User resolver. | ||
| | ||
*/ | ||
|
||
'user' => [ | ||
'morph_prefix' => 'user', | ||
'guards' => [ | ||
'web', | ||
'api', | ||
], | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Resolvers | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Define the User, IP Address, User Agent and URL resolver implementations. | ||
| | ||
*/ | ||
'resolver' => [ | ||
'user' => OwenIt\Auditing\Resolvers\UserResolver::class, | ||
'ip_address' => OwenIt\Auditing\Resolvers\IpAddressResolver::class, | ||
'user_agent' => OwenIt\Auditing\Resolvers\UserAgentResolver::class, | ||
'url' => OwenIt\Auditing\Resolvers\UrlResolver::class, | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Events | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The Eloquent events that trigger an Audit. | ||
| | ||
*/ | ||
|
||
'events' => [ | ||
'created', | ||
'updated', | ||
'deleted', | ||
'restored', | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Strict Mode | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Enable the strict mode when auditing? | ||
| | ||
*/ | ||
|
||
'strict' => false, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Timestamps | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Should the created_at, updated_at and deleted_at timestamps be audited? | ||
| | ||
*/ | ||
|
||
'timestamps' => false, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Threshold | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Specify a threshold for the amount of Audit records a model can have. | ||
| Zero means no limit. | ||
| | ||
*/ | ||
|
||
'threshold' => 0, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Driver | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The default audit driver used to keep track of changes. | ||
| | ||
*/ | ||
|
||
'driver' => 'database', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Driver Configurations | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Available audit drivers and respective configurations. | ||
| | ||
*/ | ||
|
||
'drivers' => [ | ||
'database' => [ | ||
'table' => 'audits', | ||
'connection' => null, | ||
], | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Audit Console | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Whether console events should be audited (eg. php artisan db:seed). | ||
| | ||
*/ | ||
|
||
'console' => false, | ||
]; |
43 changes: 43 additions & 0 deletions
43
database/migrations/2024_04_06_144921_create_audits_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateAuditsTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('audits', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('user_type')->nullable(); | ||
$table->unsignedBigInteger('user_id')->nullable(); | ||
$table->string('event'); | ||
$table->morphs('auditable'); | ||
$table->text('old_values')->nullable(); | ||
$table->text('new_values')->nullable(); | ||
$table->text('url')->nullable(); | ||
$table->ipAddress('ip_address')->nullable(); | ||
$table->string('user_agent')->nullable(); | ||
$table->string('tags')->nullable(); | ||
$table->timestamps(); | ||
|
||
$table->index(['user_id', 'user_type']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('audits'); | ||
} | ||
} |