diff --git a/config/db-auditor.php b/config/db-auditor.php index e0de1f7..aea6421 100644 --- a/config/db-auditor.php +++ b/config/db-auditor.php @@ -1,9 +1,18 @@ database_name(), + /* + | + |-------------------------------------------------------------------------- + | Skip tables + |-------------------------------------------------------------------------- + | + | Specify the tables that you want to skip auditing + | + | + */ + 'skip_tables' => [ // Add table name that you want to skip 'cache', 'sqlite_sequence', @@ -15,17 +24,5 @@ 'jobs', 'queue_job', 'queue_failed_jobs', - ], - 'mysql_commands' => [ - Constant::STANDARD_COMMAND, - Constant::CONSTRAINT_COMMAND, - Constant::SUMMARY_COMMAND, - Constant::TRACK_COMMAND, - ], - 'sqlite_commands' => [ - Constant::STANDARD_COMMAND, - Constant::CONSTRAINT_COMMAND, - Constant::SUMMARY_COMMAND, - Constant::TRACK_COMMAND, ] ]; diff --git a/src/Commands/DBAuditCommand.php b/src/Commands/DBAuditCommand.php index 0545f7f..8e70b43 100644 --- a/src/Commands/DBAuditCommand.php +++ b/src/Commands/DBAuditCommand.php @@ -3,6 +3,7 @@ namespace Vcian\LaravelDBAuditor\Commands; use Illuminate\Console\Command; +use League\Flysystem\Config; use Vcian\LaravelDBAuditor\Constants\Constant; use function Laravel\Prompts\select; @@ -28,9 +29,9 @@ class DBAuditCommand extends Command */ public function handle(): void { - $commands = match (connection_driver()) { - Constant::SQLITE_DB => config('db-auditor.sqlite_commands'), - Constant::MYSQL_DB => config('db-auditor.mysql_commands'), + $commands = match (connection_driver()) { + Constant::SQLITE_DB => config('audit.sqlite_commands'), + Constant::MYSQL_DB => config('audit.mysql_commands'), }; $commandSelect = select( diff --git a/src/Config/audit.php b/src/Config/audit.php new file mode 100644 index 0000000..c919d1c --- /dev/null +++ b/src/Config/audit.php @@ -0,0 +1,30 @@ + [ // Add table name that you want to skip + 'cache', + 'sqlite_sequence', + 'migrations', + 'migrations_history', + 'sessions', + 'password_resets', + 'failed_jobs', + 'jobs', + 'queue_job', + 'queue_failed_jobs', + ], + 'mysql_commands' => [ + Constant::STANDARD_COMMAND, + Constant::CONSTRAINT_COMMAND, + Constant::SUMMARY_COMMAND, + Constant::TRACK_COMMAND, + ], + 'sqlite_commands' => [ + Constant::STANDARD_COMMAND, + Constant::CONSTRAINT_COMMAND, + Constant::SUMMARY_COMMAND, + Constant::TRACK_COMMAND, + ] +]; diff --git a/src/Providers/DBAuditorServiceProvider.php b/src/Providers/DBAuditorServiceProvider.php index 3b092ac..9529c50 100644 --- a/src/Providers/DBAuditorServiceProvider.php +++ b/src/Providers/DBAuditorServiceProvider.php @@ -19,8 +19,7 @@ class DBAuditorServiceProvider extends ServiceProvider */ public function register(): void { - $this->commands($this->commands); - + $this->registerConfig(); } /** @@ -28,19 +27,54 @@ public function register(): void */ public function boot(): void { - $this->publishes([ - __DIR__ . '/../resource/images' => public_path('auditor/icon'), - ], 'public'); + if ($this->app->runningInConsole()) { + $this->registerCommands(); + $this->publishConfigs(); + } $this->loadViewsFrom(__DIR__ . '/../views', 'DBAuditor'); $this->loadRoutesFrom(__DIR__ . '/../../routes/web.php'); $this->loadRoutesFrom(__DIR__ . '/../../routes/api.php'); $this->loadHelpers(); $this->loadTranslationsFrom(__DIR__ . '/../Lang/', 'Lang'); + + } + + /** + * Register config + * @return void + */ + protected function registerConfig(): void + { $this->mergeConfigFrom(__DIR__ . '/../../config/db-auditor.php', 'db-auditor'); + $this->mergeConfigFrom(__DIR__ . '/../Config/audit.php', 'audit'); + } + + /** + * Publish configs + * @return void + */ + protected function publishConfigs(): void + { + $this->publishes([ + __DIR__ . '/../resource/images' => public_path('auditor/icon'), + ], 'public'); + + $this->publishes([ + __DIR__ . '/../../config/db-auditor.php' => config_path('db-auditor.php'), + ], 'config'); } /** + * Register commands + * @return void + */ + public function registerCommands(): void + { + $this->commands($this->commands); + } + /** + * Load helpers * @return void */ protected function loadHelpers(): void diff --git a/src/views/sqlite/standard.blade.php b/src/views/sqlite/standard.blade.php index 7782d07..adb7177 100644 --- a/src/views/sqlite/standard.blade.php +++ b/src/views/sqlite/standard.blade.php @@ -12,7 +12,6 @@ @foreach ($tableStatus as $table)