|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Compubel\Rating; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
|
|
7
|
|
|
class RatingServiceProvider extends ServiceProvider |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Perform post-registration booting of services. |
|
11
|
|
|
* |
|
12
|
|
|
* @return void |
|
13
|
|
|
*/ |
|
14
|
|
|
public function boot() |
|
15
|
|
|
{ |
|
16
|
|
|
// this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
17
|
|
|
// $this->loadRoutesFrom(__DIR__.'/routes.php'); |
|
18
|
|
|
|
|
19
|
|
|
$timestamp = date('Y_m_d_His'); |
|
20
|
|
|
|
|
21
|
|
|
$this->publishes([ |
|
22
|
|
|
__DIR__.'/../database/migrations/2019_10_19_000000_create_rating_table.php' => database_path('/migrations/'.$timestamp.'_create_rating_table.php'), |
|
23
|
|
|
], 'migrations'); |
|
24
|
|
|
|
|
25
|
|
|
$this->publishes([ |
|
26
|
|
|
__DIR__.'/../config/rating.php' => config_path('rating.php'), |
|
27
|
|
|
], 'config'); |
|
28
|
|
|
|
|
29
|
|
|
// Publishing is only necessary when using the CLI. |
|
30
|
|
|
if ($this->app->runningInConsole()) { |
|
31
|
|
|
$this->bootForConsole(); |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Register any package services. |
|
37
|
|
|
* |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
public function register() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/rating.php', 'rating'); |
|
43
|
|
|
|
|
44
|
|
|
// Register the service the package provides. |
|
45
|
|
|
// $this->app->singleton('laravel-rating', function ($app) { |
|
46
|
|
|
// return new laravel-rating; |
|
47
|
|
|
// }); |
|
48
|
|
|
// $this->app->singleton(Rating::class, function () { |
|
49
|
|
|
// return new Rating(); |
|
50
|
|
|
// }); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get the services provided by the provider. |
|
55
|
|
|
* |
|
56
|
|
|
* @return array |
|
57
|
|
|
*/ |
|
58
|
|
|
// public function provides() |
|
59
|
|
|
// { |
|
60
|
|
|
// return ['laravel-rating']; |
|
61
|
|
|
// } |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Console-specific booting. |
|
65
|
|
|
* |
|
66
|
|
|
* @return void |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function bootForConsole() |
|
69
|
|
|
{ |
|
70
|
|
|
// Publishing the configuration file. |
|
71
|
|
|
$this->publishes([ |
|
72
|
|
|
__DIR__.'/../config/rating.php' => config_path('rating.php'), |
|
73
|
|
|
], 'rating.config'); |
|
74
|
|
|
|
|
75
|
|
|
// Registering package commands. |
|
76
|
|
|
// $this->commands([]); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|