Completed
Push — master ( 964bf5...68f39a )
by Abdelrahman
02:50 queued 01:47
created

FormsServiceProvider::publishResources()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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']);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 132 characters

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.

Loading history...
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