Skip to content

Commit 2b693d1

Browse files
committed
Add db-audit file as publish file.
Resolved minor bugs.
1 parent ad625c4 commit 2b693d1

File tree

5 files changed

+84
-23
lines changed

5 files changed

+84
-23
lines changed

config/db-auditor.php

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
<?php
22
// config for Vcian/LaravelDbAuditor
3-
use Vcian\LaravelDBAuditor\Constants\Constant;
43

54
return [
6-
'db_name' => database_name(),
5+
/*
6+
|
7+
|--------------------------------------------------------------------------
8+
| Skip tables
9+
|--------------------------------------------------------------------------
10+
|
11+
| Specify the tables that you want to skip auditing
12+
|
13+
|
14+
*/
15+
716
'skip_tables' => [ // Add table name that you want to skip
817
'cache',
918
'sqlite_sequence',
@@ -15,17 +24,5 @@
1524
'jobs',
1625
'queue_job',
1726
'queue_failed_jobs',
18-
],
19-
'mysql_commands' => [
20-
Constant::STANDARD_COMMAND,
21-
Constant::CONSTRAINT_COMMAND,
22-
Constant::SUMMARY_COMMAND,
23-
Constant::TRACK_COMMAND,
24-
],
25-
'sqlite_commands' => [
26-
Constant::STANDARD_COMMAND,
27-
Constant::CONSTRAINT_COMMAND,
28-
Constant::SUMMARY_COMMAND,
29-
Constant::TRACK_COMMAND,
3027
]
3128
];

src/Commands/DBAuditCommand.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Vcian\LaravelDBAuditor\Commands;
44

55
use Illuminate\Console\Command;
6+
use League\Flysystem\Config;
67
use Vcian\LaravelDBAuditor\Constants\Constant;
78

89
use function Laravel\Prompts\select;
@@ -28,9 +29,9 @@ class DBAuditCommand extends Command
2829
*/
2930
public function handle(): void
3031
{
31-
$commands = match (connection_driver()) {
32-
Constant::SQLITE_DB => config('db-auditor.sqlite_commands'),
33-
Constant::MYSQL_DB => config('db-auditor.mysql_commands'),
32+
$commands = match (connection_driver()) {
33+
Constant::SQLITE_DB => config('audit.sqlite_commands'),
34+
Constant::MYSQL_DB => config('audit.mysql_commands'),
3435
};
3536

3637
$commandSelect = select(

src/Config/audit.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
// config for Vcian/LaravelDbAuditor
3+
use Vcian\LaravelDBAuditor\Constants\Constant;
4+
5+
return [
6+
'skip_tables' => [ // Add table name that you want to skip
7+
'cache',
8+
'sqlite_sequence',
9+
'migrations',
10+
'migrations_history',
11+
'sessions',
12+
'password_resets',
13+
'failed_jobs',
14+
'jobs',
15+
'queue_job',
16+
'queue_failed_jobs',
17+
],
18+
'mysql_commands' => [
19+
Constant::STANDARD_COMMAND,
20+
Constant::CONSTRAINT_COMMAND,
21+
Constant::SUMMARY_COMMAND,
22+
Constant::TRACK_COMMAND,
23+
],
24+
'sqlite_commands' => [
25+
Constant::STANDARD_COMMAND,
26+
Constant::CONSTRAINT_COMMAND,
27+
Constant::SUMMARY_COMMAND,
28+
Constant::TRACK_COMMAND,
29+
]
30+
];

src/Providers/DBAuditorServiceProvider.php

+39-5
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,62 @@ class DBAuditorServiceProvider extends ServiceProvider
1919
*/
2020
public function register(): void
2121
{
22-
$this->commands($this->commands);
23-
22+
$this->registerConfig();
2423
}
2524

2625
/**
2726
* Bootstrap services.
2827
*/
2928
public function boot(): void
3029
{
31-
$this->publishes([
32-
__DIR__ . '/../resource/images' => public_path('auditor/icon'),
33-
], 'public');
30+
if ($this->app->runningInConsole()) {
31+
$this->registerCommands();
32+
$this->publishConfigs();
33+
}
3434

3535
$this->loadViewsFrom(__DIR__ . '/../views', 'DBAuditor');
3636
$this->loadRoutesFrom(__DIR__ . '/../../routes/web.php');
3737
$this->loadRoutesFrom(__DIR__ . '/../../routes/api.php');
3838
$this->loadHelpers();
3939
$this->loadTranslationsFrom(__DIR__ . '/../Lang/', 'Lang');
40+
41+
}
42+
43+
/**
44+
* Register config
45+
* @return void
46+
*/
47+
protected function registerConfig(): void
48+
{
4049
$this->mergeConfigFrom(__DIR__ . '/../../config/db-auditor.php', 'db-auditor');
50+
$this->mergeConfigFrom(__DIR__ . '/../Config/audit.php', 'audit');
51+
}
52+
53+
/**
54+
* Publish configs
55+
* @return void
56+
*/
57+
protected function publishConfigs(): void
58+
{
59+
$this->publishes([
60+
__DIR__ . '/../resource/images' => public_path('auditor/icon'),
61+
], 'public');
62+
63+
$this->publishes([
64+
__DIR__ . '/../../config/db-auditor.php' => config_path('db-auditor.php'),
65+
], 'config');
4166
}
4267

4368
/**
69+
* Register commands
70+
* @return void
71+
*/
72+
public function registerCommands(): void
73+
{
74+
$this->commands($this->commands);
75+
}
76+
/**
77+
* Load helpers
4478
* @return void
4579
*/
4680
protected function loadHelpers(): void

src/views/sqlite/standard.blade.php

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
@foreach ($tableStatus as $table)
1313
<div class="flex space-x-1">
1414
<span>{{ $table['name'] }}</span>
15-
<i class="text-blue">({{ $table['size'] }} MB)</i>
1615
<span class="flex-1 content-repeat-[.] text-gray"></span>
1716
@if ($table['status'])
1817
@php $success++; @endphp

0 commit comments

Comments
 (0)