|
1 | 1 | <?php namespace GeneaLabs\LaravelMixpanel\Providers; |
2 | 2 |
|
3 | | -use GeneaLabs\LaravelMixpanel\LaravelMixpanel; |
4 | | -use GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelEventHandler; |
5 | | -use GeneaLabs\LaravelMixpanel\Listeners\LaravelMixpanelUserObserver; |
6 | | -use GeneaLabs\LaravelMixpanel\Console\Commands\Publish; |
7 | | -use GeneaLabs\LaravelMixpanel\Events\MixpanelEvent; |
8 | | -use GeneaLabs\LaravelMixpanel\Listeners\MixpanelEvent as MixpanelEventListener; |
9 | | -use Illuminate\Contracts\View\View; |
10 | | -use Illuminate\HTTP\Request; |
11 | | -use Illuminate\Support\ServiceProvider; |
12 | | -use Illuminate\Foundation\Support\Providers\EventServiceProvider; |
13 | 3 | use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; |
14 | 4 |
|
15 | | -class LaravelMixpanelService extends EventServiceProvider |
16 | | -{ |
17 | | - protected $defer = false; |
18 | | - protected $listen = [ |
19 | | - MixpanelEvent::class => [ |
20 | | - MixpanelEventListener::class, |
21 | | - ], |
22 | | - ]; |
23 | | - |
24 | | - public function boot(DispatcherContract $events) |
| 5 | +if (starts_with(app()->version(), '5.1.')) { |
| 6 | + class LaravelMixpanelService extends MixpanelBaseService |
25 | 7 | { |
26 | | - parent::boot($events); |
27 | | - |
28 | | - include __DIR__ . '/../../routes/api.php'; |
| 8 | + public function boot(DispatcherContract $events) |
| 9 | + { |
| 10 | + parent::boot($events); |
29 | 11 |
|
30 | | - $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'genealabs-laravel-mixpanel'); |
31 | | - $this->publishes([ |
32 | | - __DIR__ . '/../../public' => public_path(), |
33 | | - ], 'assets'); |
34 | | - |
35 | | - if (config('services.mixpanel.enable-default-tracking')) { |
36 | | - $authModel = config('auth.providers.users.model') ?? config('auth.model'); |
37 | | - $this->app->make($authModel)->observe(new LaravelMixpanelUserObserver()); |
38 | | - app('events')->subscribe(new LaravelMixpanelEventHandler()); |
| 12 | + $this->initialize(); |
39 | 13 | } |
40 | 14 | } |
41 | | - |
42 | | - public function register() |
| 15 | +} else { |
| 16 | + class LaravelMixpanelService extends MixpanelBaseService |
43 | 17 | { |
44 | | - $this->mergeConfigFrom(__DIR__ . '/../../config/services.php', 'services'); |
45 | | - $this->commands(Publish::class); |
46 | | - $this->app->singleton('mixpanel', LaravelMixpanel::class); |
47 | | - } |
| 18 | + public function boot() |
| 19 | + { |
| 20 | + parent::boot(); |
48 | 21 |
|
49 | | - /** |
50 | | - * @return array |
51 | | - */ |
52 | | - public function provides() |
53 | | - { |
54 | | - return ['genealabs-laravel-mixpanel']; |
| 22 | + $this->initialize(); |
| 23 | + } |
55 | 24 | } |
56 | 25 | } |
0 commit comments