1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sfneal\Tracking\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Sfneal\Tracking\Console\CleanDevTrackingCommand; |
7
|
|
|
|
8
|
|
|
class TrackingServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Bootstrap any Tracking services. |
12
|
|
|
* |
13
|
|
|
* @return void |
14
|
|
|
*/ |
15
|
|
|
public function boot() |
16
|
|
|
{ |
17
|
|
|
// Publish config file (before migrations in case config values are used in migrations) |
18
|
|
|
$this->publishes([ |
19
|
|
|
__DIR__.'/../../config/tracking.php' => config_path('tracking.php'), |
20
|
|
|
], 'config'); |
21
|
|
|
|
22
|
|
|
// `TrackActivity` migration file |
23
|
|
|
if (! class_exists('CreateTrackActionTable')) { |
24
|
|
|
$this->publishes([ |
25
|
|
|
__DIR__.'/../../database/migrations/create_track_action_table.php.stub' => database_path( |
26
|
|
|
'migrations/'.date('Y_m_d_His', time()).'_create_track_action_table.php' |
27
|
|
|
), |
28
|
|
|
], 'migration'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// `TrackAction` migration file |
32
|
|
|
if (! class_exists('CreateTrackActivityTable')) { |
33
|
|
|
$this->publishes([ |
34
|
|
|
__DIR__.'/../../database/migrations/create_track_activity_table.php.stub' => database_path( |
35
|
|
|
'migrations/'.date('Y_m_d_His', time()).'_create_track_activity_table.php' |
36
|
|
|
), |
37
|
|
|
], 'migration'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// `TrackTraffic` migration file |
41
|
|
|
if (! class_exists('CreateTrackTrafficTable')) { |
42
|
|
|
$this->publishes([ |
43
|
|
|
__DIR__.'/../../database/migrations/create_track_traffic_table.php.stub' => database_path( |
44
|
|
|
'migrations/'.date('Y_m_d_His', time()).'_create_track_traffic_table.php' |
45
|
|
|
), |
46
|
|
|
], 'migration'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
// Publish the `CleanDevTrackingCommand` |
50
|
|
|
if ($this->app->runningInConsole()) { |
51
|
|
|
$this->commands([ |
52
|
|
|
CleanDevTrackingCommand::class, |
53
|
|
|
]); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Register any Tracking services. |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function register() |
63
|
|
|
{ |
64
|
|
|
// Load config file |
65
|
|
|
$this->mergeConfigFrom(__DIR__.'/../../config/tracking.php', 'tracking'); |
66
|
|
|
|
67
|
|
|
// Register Event ServiceProvider |
68
|
|
|
$this->app->register(TrackingEventServiceProvider::class); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|