/
AuditingServiceProvider.php
67 lines (59 loc) · 1.79 KB
/
AuditingServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace OwenIt\Auditing;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
use OwenIt\Auditing\Console\AuditDriverCommand;
use OwenIt\Auditing\Console\AuditResolverCommand;
use OwenIt\Auditing\Console\InstallCommand;
use OwenIt\Auditing\Contracts\Auditor;
class AuditingServiceProvider extends ServiceProvider
{
/**
* Bootstrap the service provider.
*
* @return void
*/
public function boot()
{
$this->registerPublishing();
$this->mergeConfigFrom(__DIR__ . '/../config/audit.php', 'audit');
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->commands([
AuditDriverCommand::class,
AuditResolverCommand::class,
InstallCommand::class,
]);
$this->app->singleton(Auditor::class, function ($app) {
return new \OwenIt\Auditing\Auditor($app);
});
$this->app->register(AuditingEventServiceProvider::class);
}
/**
* Register the package's publishable resources.
*
* @return void
*/
private function registerPublishing()
{
if ($this->app->runningInConsole()) {
// Lumen lacks a config_path() helper, so we use base_path()
$this->publishes([
__DIR__ . '/../config/audit.php' => base_path('config/audit.php'),
], 'config');
if (!class_exists('CreateAuditsTable')) {
$this->publishes([
__DIR__ . '/../database/migrations/audits.stub' => database_path(
sprintf('migrations/%s_create_audits_table.php', date('Y_m_d_His'))
),
], 'migrations');
}
}
}
}