1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Rinvex\Attributes\Providers; |
6
|
|
|
|
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
use Rinvex\Attributes\Models\Attribute; |
9
|
|
|
use Rinvex\Support\Traits\ConsoleTools; |
10
|
|
|
use Rinvex\Attributes\Models\AttributeEntity; |
11
|
|
|
use Rinvex\Attributes\Console\Commands\MigrateCommand; |
12
|
|
|
use Rinvex\Attributes\Console\Commands\PublishCommand; |
13
|
|
|
use Rinvex\Attributes\Console\Commands\RollbackCommand; |
14
|
|
|
|
15
|
|
|
class AttributesServiceProvider 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.attributes.migrate', |
26
|
|
|
PublishCommand::class => 'command.rinvex.attributes.publish', |
27
|
|
|
RollbackCommand::class => 'command.rinvex.attributes.rollback', |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inheritdoc} |
32
|
|
|
*/ |
33
|
|
|
public function register() |
34
|
|
|
{ |
35
|
|
|
// Merge config |
36
|
|
|
$this->mergeConfigFrom(realpath(__DIR__.'/../../config/config.php'), 'rinvex.attributes'); |
37
|
|
|
|
38
|
|
|
// Bind eloquent models to IoC container |
39
|
|
|
$this->app->singleton('rinvex.attributes.attribute', $attributeyModel = $this->app['config']['rinvex.attributes.models.attribute']); |
40
|
|
|
$attributeyModel === Attribute::class || $this->app->alias('rinvex.attributes.attribute', Attribute::class); |
41
|
|
|
|
42
|
|
|
$this->app->singleton('rinvex.attributes.attribute_entity', $attributeEntityModel = $this->app['config']['rinvex.attributes.models.attribute_entity']); |
43
|
|
|
$attributeEntityModel === AttributeEntity::class || $this->app->alias('rinvex.attributes.attribute_entity', AttributeEntity::class); |
44
|
|
|
|
45
|
|
|
// Register attributes entities |
46
|
|
|
$this->app->singleton('rinvex.attributes.entities', function ($app) { |
|
|
|
|
47
|
|
|
return collect(); |
48
|
|
|
}); |
49
|
|
|
|
50
|
|
|
// Register console commands |
51
|
|
|
$this->registerCommands($this->commands); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritdoc} |
56
|
|
|
*/ |
57
|
|
|
public function boot() |
58
|
|
|
{ |
59
|
|
|
// Publish Resources |
60
|
|
|
$this->publishesConfig('rinvex/laravel-attributes'); |
61
|
|
|
$this->publishesMigrations('rinvex/laravel-attributes'); |
62
|
|
|
! $this->autoloadMigrations('rinvex/laravel-attributes') || $this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.