|
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->mergeConfigFrom( |
|
31
|
|
|
__DIR__.'/../config/webfactor/documents.php', 'webfactor.documents' |
|
32
|
|
|
); |
|
33
|
|
|
|
|
34
|
|
|
$this->publishFiles(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Register any package services. |
|
39
|
|
|
* |
|
40
|
|
|
* @return void |
|
41
|
|
|
*/ |
|
42
|
|
|
public function register() |
|
43
|
|
|
{ |
|
44
|
|
|
// |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function publishFiles() |
|
48
|
|
|
{ |
|
49
|
|
|
// publish config file |
|
50
|
|
|
$this->publishes([__DIR__.'/../config' => config_path()], 'config'); |
|
51
|
|
|
|
|
52
|
|
|
// publish lang files |
|
53
|
|
|
$this->publishes([__DIR__.'/../resources/lang' => resource_path('lang/vendor/webfactor')], 'lang'); |
|
54
|
|
|
|
|
55
|
|
|
// publish migrations |
|
56
|
|
|
$this->publishes([__DIR__.'/../database/migrations' => database_path('migrations')], 'migrations'); |
|
57
|
|
|
|
|
58
|
|
|
// publish seeder |
|
59
|
|
|
$this->publishes([__DIR__.'/../database/seeds' => database_path('seeds')], 'seeder'); |
|
60
|
|
|
|
|
61
|
|
|
// publish factory |
|
62
|
|
|
$this->publishes([__DIR__.'/../database/factories' => database_path('factories')], 'factories'); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Define the routes for the application. |
|
67
|
|
|
* |
|
68
|
|
|
* @param \Illuminate\Routing\Router $router |
|
69
|
|
|
* |
|
70
|
|
|
* @return void |
|
71
|
|
|
*/ |
|
72
|
|
|
public function setupRoutes(Router $router) |
|
|
|
|
|
|
73
|
|
|
{ |
|
74
|
|
|
// by default, use the routes file provided in vendor |
|
75
|
|
|
$routeFilePathInUse = __DIR__.$this->routeFilePath; |
|
76
|
|
|
|
|
77
|
|
|
// but if there's a file with the same name in routes/webfactor, use that one |
|
78
|
|
|
if (file_exists(base_path().$this->routeFilePath)) { |
|
79
|
|
|
$routeFilePathInUse = base_path().$this->routeFilePath; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$this->loadRoutesFrom($routeFilePathInUse); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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: