1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Webfactor\Laravel\Backpack\Documents; |
4
|
|
|
|
5
|
|
|
use Illuminate\Routing\Router; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
class DocumentsServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Where the route file lives, both inside the package and in the app (if overwritten). |
13
|
|
|
* |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
public $routeFilePath = '/../routes/webfactor/documents.php'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Perform post-registration booting of services. |
20
|
|
|
* |
21
|
|
|
* @return void |
22
|
|
|
*/ |
23
|
|
|
public function boot() |
24
|
|
|
{ |
25
|
|
|
// define the routes for the application |
26
|
|
|
$this->setupRoutes($this->app->router); |
|
|
|
|
27
|
|
|
|
28
|
|
|
$this->loadTranslationsFrom(realpath(__DIR__.'/../resources/lang'), 'webfactor'); |
29
|
|
|
|
30
|
|
|
$this->publishFiles(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Register any package services. |
35
|
|
|
* |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
|
|
public function register() |
39
|
|
|
{ |
40
|
|
|
$this->mergeConfigFrom( |
41
|
|
|
__DIR__.'/../config/webfactor/documents.php', 'webfactor.documents' |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function publishFiles() |
46
|
|
|
{ |
47
|
|
|
// publish config file |
48
|
|
|
$this->publishes([__DIR__.'/../config' => config_path()], 'config'); |
49
|
|
|
|
50
|
|
|
// publish lang files |
51
|
|
|
$this->publishes([__DIR__.'/../resources/lang' => resource_path('lang/vendor/webfactor')], 'lang'); |
52
|
|
|
|
53
|
|
|
// publish migrations |
54
|
|
|
$this->publishes([__DIR__.'/../database/migrations' => database_path('migrations')], 'migrations'); |
55
|
|
|
|
56
|
|
|
// publish seeder |
57
|
|
|
$this->publishes([__DIR__.'/../database/seeds' => database_path('seeds')], 'seeder'); |
58
|
|
|
|
59
|
|
|
// publish factory |
60
|
|
|
$this->publishes([__DIR__.'/../database/factories' => database_path('factories')], 'factories'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Define the routes for the application. |
65
|
|
|
* |
66
|
|
|
* @param \Illuminate\Routing\Router $router |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
public function setupRoutes(Router $router) |
|
|
|
|
71
|
|
|
{ |
72
|
|
|
// by default, use the routes file provided in vendor |
73
|
|
|
$routeFilePathInUse = __DIR__.$this->routeFilePath; |
74
|
|
|
|
75
|
|
|
// but if there's a file with the same name in routes/webfactor, use that one |
76
|
|
|
if (file_exists(base_path().$this->routeFilePath)) { |
77
|
|
|
$routeFilePathInUse = base_path().$this->routeFilePath; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$this->loadRoutesFrom($routeFilePathInUse); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: