1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thinktomorrow\Chief\App\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Console\Scheduling\Schedule; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Thinktomorrow\Chief\Admin\Authorization\Console\GeneratePermissionCommand; |
8
|
|
|
use Thinktomorrow\Chief\Admin\Authorization\Console\GenerateRoleCommand; |
9
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreateFragmentCommand; |
10
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreatePageCommand; |
11
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreatePageMigrationCommand; |
12
|
|
|
use Thinktomorrow\Chief\Admin\Setup\CreateViewCommand; |
13
|
|
|
use Thinktomorrow\Chief\Admin\Setup\FileManipulation; |
14
|
|
|
use Thinktomorrow\Chief\Admin\Setup\SetupConfig; |
15
|
|
|
use Thinktomorrow\Chief\App\Console\CreateAdmin; |
16
|
|
|
use Thinktomorrow\Chief\App\Console\CreateDeveloper; |
17
|
|
|
use Thinktomorrow\Chief\App\Console\RefreshDatabase; |
18
|
|
|
use Thinktomorrow\Chief\App\Console\Seed; |
19
|
|
|
|
20
|
|
|
class ConsoleServiceProvider extends ServiceProvider |
21
|
|
|
{ |
22
|
|
|
public function boot(): void |
23
|
|
|
{ |
24
|
|
|
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
25
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'chief'); |
26
|
|
|
|
27
|
|
|
$this->publishes([ |
28
|
|
|
__DIR__.'/../../config/chief.php' => config_path('chief.php'), |
29
|
|
|
__DIR__.'/../../config/chief-settings.php' => config_path('chief-settings.php'), |
30
|
|
|
], 'chief-config'); |
31
|
|
|
|
32
|
|
|
$this->publishes([ |
33
|
|
|
__DIR__.'/../../public/chief-assets' => public_path('/chief-assets'), |
34
|
|
|
], 'chief-assets'); |
35
|
|
|
|
36
|
|
|
$this->commands([ |
37
|
|
|
// Local development |
38
|
|
|
'command.chief:refresh', |
39
|
|
|
'command.chief:seed', |
40
|
|
|
|
41
|
|
|
// Project setup tools |
42
|
|
|
'command.chief:permission', |
43
|
|
|
'command.chief:role', |
44
|
|
|
|
45
|
|
|
'command.chief:admin', |
46
|
|
|
'command.chief:developer', |
47
|
|
|
'command.chief:page', |
48
|
|
|
'command.chief:page-migration', |
49
|
|
|
'command.chief:fragment', |
50
|
|
|
'command.chief:view', |
51
|
|
|
]); |
52
|
|
|
|
53
|
|
|
// Bind our commands to the container |
54
|
|
|
$this->app->bind('command.chief:refresh', RefreshDatabase::class); |
55
|
|
|
$this->app->bind('command.chief:seed', Seed::class); |
56
|
|
|
$this->app->bind('command.chief:permission', GeneratePermissionCommand::class); |
57
|
|
|
$this->app->bind('command.chief:role', GenerateRoleCommand::class); |
58
|
|
|
|
59
|
|
|
$this->app->bind('command.chief:page', CreatePageCommand::class); |
60
|
|
|
$this->app->bind('command.chief:page-migration', CreatePageMigrationCommand::class); |
61
|
|
|
$this->app->bind('command.chief:view', CreateViewCommand::class); |
62
|
|
|
$this->app->bind('command.chief:fragment', CreateFragmentCommand::class); |
63
|
|
|
$this->app->bind('command.chief:admin', CreateAdmin::class); |
64
|
|
|
$this->app->bind('command.chief:developer', CreateDeveloper::class); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function register() |
68
|
|
|
{ |
69
|
|
|
$this->callAfterResolving(Schedule::class, function (Schedule $schedule) { |
70
|
|
|
$schedule->command('chief:sitemap')->dailyAt('01:00'); |
71
|
|
|
}); |
72
|
|
|
|
73
|
|
|
// Setup commands |
74
|
|
|
$this->app->bind(CreatePageCommand::class, function ($app) { |
75
|
|
|
return new CreatePageCommand($app->make(FileManipulation::class), new SetupConfig(config('chief.setup', []))); |
76
|
|
|
}); |
77
|
|
|
|
78
|
|
|
$this->app->bind(CreateFragmentCommand::class, function ($app) { |
79
|
|
|
return new CreateFragmentCommand($app->make(FileManipulation::class), new SetupConfig(config('chief.setup', []))); |
80
|
|
|
}); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|