1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Rinvex\Forms\Providers; |
6
|
|
|
|
7
|
|
|
use Rinvex\Forms\Models\Form; |
8
|
|
|
use Rinvex\Forms\Models\FormResponse; |
9
|
|
|
use Illuminate\Support\ServiceProvider; |
10
|
|
|
use Rinvex\Support\Traits\ConsoleTools; |
11
|
|
|
use Rinvex\Forms\Console\Commands\MigrateCommand; |
12
|
|
|
use Rinvex\Forms\Console\Commands\PublishCommand; |
13
|
|
|
use Rinvex\Forms\Console\Commands\RollbackCommand; |
14
|
|
|
|
15
|
|
|
class FormsServiceProvider extends ServiceProvider |
16
|
|
|
{ |
17
|
|
|
use ConsoleTools; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The commands to be registered. |
21
|
|
|
* |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected $commands = [ |
25
|
|
|
MigrateCommand::class => 'command.rinvex.forms.migrate', |
26
|
|
|
PublishCommand::class => 'command.rinvex.forms.publish', |
27
|
|
|
RollbackCommand::class => 'command.rinvex.forms.rollback', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function register() |
34
|
|
|
{ |
35
|
|
|
// Merge config |
36
|
|
|
$this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'rinvex.forms'); |
37
|
|
|
|
38
|
|
|
// Bind eloquent models to IoC container |
39
|
|
|
$this->app->singleton('rinvex.forms.form', $formModel = $this->app['config']['rinvex.forms.models.form']); |
40
|
|
|
$formModel === Form::class || $this->app->alias('rinvex.forms.form', Form::class); |
41
|
|
|
|
42
|
|
|
$this->app->singleton('rinvex.forms.form_response', $formModel = $this->app['config']['rinvex.forms.models.form_response']); |
|
|
|
|
43
|
|
|
$formModel === FormResponse::class || $this->app->alias('rinvex.forms.form_response', FormResponse::class); |
44
|
|
|
|
45
|
|
|
// Register console commands |
46
|
|
|
! $this->app->runningInConsole() || $this->registerCommands(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public function boot() |
53
|
|
|
{ |
54
|
|
|
// Publish Resources |
55
|
|
|
! $this->app->runningInConsole() || $this->publishesConfig('rinvex/laravel-forms'); |
56
|
|
|
! $this->app->runningInConsole() || $this->publishesMigrations('rinvex/laravel-forms'); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.