|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Spatie\EmailCampaigns; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Event; |
|
6
|
|
|
use Illuminate\Support\Facades\Route; |
|
7
|
|
|
use Illuminate\Mail\Events\MessageSent; |
|
8
|
|
|
use Illuminate\Support\ServiceProvider; |
|
9
|
|
|
use Spatie\EmailCampaigns\Commands\RetryPendingSendsCommand; |
|
10
|
|
|
use Spatie\EmailCampaigns\Listeners\StoreTransportMessageId; |
|
11
|
|
|
use Spatie\EmailCampaigns\Commands\CalculateStatisticsCommand; |
|
12
|
|
|
use Spatie\EmailCampaigns\Http\Controllers\TrackOpensController; |
|
13
|
|
|
use Spatie\EmailCampaigns\Http\Controllers\TrackClicksController; |
|
14
|
|
|
use Spatie\EmailCampaigns\Http\Controllers\UnsubscribeController; |
|
15
|
|
|
use Spatie\EmailCampaigns\Http\Controllers\CampaignWebviewController; |
|
16
|
|
|
use Spatie\EmailCampaigns\Http\Controllers\ConfirmSubscriptionController; |
|
17
|
|
|
|
|
18
|
|
|
class EmailCampaignsServiceProvider extends ServiceProvider |
|
19
|
|
|
{ |
|
20
|
|
|
public function boot() |
|
21
|
|
|
{ |
|
22
|
|
|
$this |
|
23
|
|
|
->registerViews() |
|
24
|
|
|
->registerTranslations() |
|
25
|
|
|
->registerPublishables() |
|
26
|
|
|
->registerRoutes(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function register() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/email-campaigns.php', 'email-campaigns'); |
|
32
|
|
|
|
|
33
|
|
|
$this->registerCommands(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function registerViews() |
|
37
|
|
|
{ |
|
38
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'email-campaigns'); |
|
39
|
|
|
|
|
40
|
|
|
return $this; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function registerTranslations() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang/', 'email-campaigns'); |
|
46
|
|
|
|
|
47
|
|
|
return $this; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function registerPublishables() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->publishes([ |
|
53
|
|
|
__DIR__.'/../resources/views' => resource_path('views/vendor/email-campaigns'), |
|
54
|
|
|
], 'views'); |
|
55
|
|
|
|
|
56
|
|
|
$this->publishes([ |
|
57
|
|
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/email-campaigns'), |
|
58
|
|
|
]); |
|
59
|
|
|
|
|
60
|
|
|
$this->publishes([ |
|
61
|
|
|
__DIR__.'/../config/email-campaigns.php' => config_path('email-campaigns.php'), |
|
62
|
|
|
], 'config'); |
|
63
|
|
|
|
|
64
|
|
|
if (! class_exists('CreateEmailCampaignTables')) { |
|
65
|
|
|
$this->publishes([ |
|
66
|
|
|
__DIR__.'/../database/migrations/create_email_campaign_tables.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_email_campaign_tables.php'), |
|
67
|
|
|
], 'migrations'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
protected function registerRoutes() |
|
74
|
|
|
{ |
|
75
|
|
|
Route::macro('emailCampaigns', function () { |
|
76
|
|
|
Route::get('/confirm-subscription/{subscriptionUuid}', ConfirmSubscriptionController::class); |
|
77
|
|
|
Route::match(['get', 'post'], '/unsubscribe/{subscriptionUuid}/{campaignSendUuid?}', UnsubscribeController::class); |
|
78
|
|
|
|
|
79
|
|
|
Route::get('/opens/{campaignSendUuid}', TrackOpensController::class); |
|
80
|
|
|
Route::get('/links/{campaignLinkUuid}/{subscriberUuid}', TrackClicksController::class); |
|
81
|
|
|
|
|
82
|
|
|
Route::get('webview/{campaignUuid}', CampaignWebviewController::class); |
|
83
|
|
|
}); |
|
84
|
|
|
|
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
protected function registerCommands() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->app->bind('command.email-campaigns:calculate-statistics', CalculateStatisticsCommand::class); |
|
91
|
|
|
$this->app->bind('command.email-campaigns:retry-pending-sends', RetryPendingSendsCommand::class); |
|
92
|
|
|
|
|
93
|
|
|
$this->commands([ |
|
94
|
|
|
'command.email-campaigns:calculate-statistics', |
|
95
|
|
|
'command.email-campaigns:retry-pending-sends', |
|
96
|
|
|
]); |
|
97
|
|
|
|
|
98
|
|
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|