|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ProtoneMedia\LaravelVerifyNewEmail; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
6
|
|
|
use Illuminate\Support\Collection; |
|
7
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
|
8
|
|
|
|
|
9
|
|
|
class ServiceProvider extends BaseServiceProvider |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Bootstrap the application services. |
|
13
|
|
|
*/ |
|
14
|
|
|
public function boot(Filesystem $filesystem) |
|
15
|
|
|
{ |
|
16
|
|
|
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'verify-new-email'); |
|
17
|
|
|
|
|
18
|
|
|
if (!config('verify-new-email.route')) { |
|
19
|
|
|
$this->loadRoutesFrom(__DIR__ . '/routes.php'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
if ($this->app->runningInConsole()) { |
|
23
|
|
|
$this->publishes([ |
|
24
|
|
|
__DIR__ . '/../database/migrations/create_pending_user_emails_table.php.stub' => $this->getMigrationFileName($filesystem), |
|
25
|
|
|
], 'migrations'); |
|
26
|
|
|
|
|
27
|
|
|
$this->publishes([ |
|
28
|
|
|
__DIR__ . '/../config/config.php' => config_path('verify-new-email.php'), |
|
29
|
|
|
], 'config'); |
|
30
|
|
|
|
|
31
|
|
|
$this->publishes([ |
|
32
|
|
|
__DIR__ . '/../resources/views' => resource_path('views/vendor/verify-new-email'), |
|
33
|
|
|
], 'views'); |
|
34
|
|
|
|
|
35
|
|
|
// $this->commands([]); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Returns existing migration file if found, else uses the current timestamp. |
|
41
|
|
|
* |
|
42
|
|
|
* @param Filesystem $filesystem |
|
43
|
|
|
* @return string |
|
44
|
|
|
*/ |
|
45
|
|
|
protected function getMigrationFileName(Filesystem $filesystem): string |
|
46
|
|
|
{ |
|
47
|
|
|
$timestamp = date('Y_m_d_His'); |
|
48
|
|
|
|
|
49
|
|
|
return Collection::make($this->app->databasePath('migrations') . DIRECTORY_SEPARATOR) |
|
50
|
|
|
->flatMap(function ($path) use ($filesystem) { |
|
51
|
|
|
return $filesystem->glob("{$path}*_create_pending_user_emails_table.php"); |
|
52
|
|
|
}) |
|
53
|
|
|
->push($this->app->databasePath("migrations/{$timestamp}_create_pending_user_emails_table.php")) |
|
54
|
|
|
->first(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Register the application services. |
|
59
|
|
|
*/ |
|
60
|
|
|
public function register() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'verify-new-email'); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|