1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace mathewparet\LaravelInvites; |
4
|
|
|
|
5
|
|
|
use mathewparet\LaravelInvites\LaravelInvites; |
6
|
|
|
use mathewparet\LaravelInvites\Commands\GenerateInvitations; |
7
|
|
|
use mathewparet\LaravelInvites\Commands\CheckInvitation; |
8
|
|
|
use mathewparet\LaravelInvites\Commands\Cleanup; |
9
|
|
|
|
10
|
|
|
use Illuminate\Support\ServiceProvider; |
11
|
|
|
use Validator; |
12
|
|
|
|
13
|
|
|
class LaravelInvitesServiceProvider extends ServiceProvider |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Perform post-registration booting of services. |
17
|
|
|
* |
18
|
|
|
* @return void |
19
|
|
|
*/ |
20
|
|
|
public function boot() |
21
|
|
|
{ |
22
|
|
|
$this->loadMigrationsFrom(__DIR__.'/database/migrations'); |
23
|
|
|
$this->loadRoutesFrom(__DIR__.'/Routes/web.php'); |
24
|
|
|
$this->loadViewsFrom(__DIR__.'/Views', 'laravelinvites'); |
25
|
|
|
|
26
|
|
|
// Publishing is only necessary when using the CLI. |
27
|
|
|
if ($this->app->runningInConsole()) { |
28
|
|
|
$this->bootForConsole(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
$this->publishes([ |
32
|
|
|
__DIR__.'/../config/laravelinvites.php' => config_path('laravelinvites.php'), |
33
|
|
|
], 'config'); |
34
|
|
|
|
35
|
|
|
$this->publishes([ |
36
|
|
|
__DIR__.'/Views/Mail/InvitationMailMarkdown.blade.php' => base_path('resources/views/Mail/InvitationMailMarkdown.blade.php'), |
37
|
|
|
], 'mail'); |
38
|
|
|
|
39
|
|
|
Validator::extend('valid_code', LaravelInvites::class.'@validate', 'The :attribute is invalid.'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Register any package services. |
44
|
|
|
* |
45
|
|
|
* @return void |
46
|
|
|
*/ |
47
|
|
|
public function register() |
48
|
|
|
{ |
49
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/laravelinvites.php', 'laravelinvites'); |
50
|
|
|
|
51
|
|
|
// Register the service the package provides. |
52
|
|
|
$this->app->singleton('laravelinvites', function(/** @scrutinizer ignore-unused */ $app) { |
53
|
|
|
return new LaravelInvites; |
54
|
|
|
}); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Get the services provided by the provider. |
59
|
|
|
* |
60
|
|
|
* @return array |
61
|
|
|
*/ |
62
|
|
|
public function provides() |
63
|
|
|
{ |
64
|
|
|
return ['laravelinvites']; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Console-specific booting. |
69
|
|
|
* |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
|
|
protected function bootForConsole() |
73
|
|
|
{ |
74
|
|
|
// Publishing the configuration file. |
75
|
|
|
$this->publishes([ |
76
|
|
|
__DIR__.'/../config/laravelinvites.php' => config_path('laravelinvites.php'), |
77
|
|
|
], 'config'); |
78
|
|
|
|
79
|
|
|
// Registering package commands. |
80
|
|
|
$this->commands([ |
81
|
|
|
GenerateInvitations::class, |
82
|
|
|
CheckInvitation::class, |
83
|
|
|
Cleanup::class, |
84
|
|
|
]); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|