| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Spinen\QuickBooks\Providers; |
||||
| 4 | |||||
| 5 | use Illuminate\Routing\Router; |
||||
| 6 | use Illuminate\Support\ServiceProvider as LaravelServiceProvider; |
||||
| 7 | use Spinen\QuickBooks\Http\Middleware\Filter; |
||||
| 8 | |||||
| 9 | /** |
||||
| 10 | * Class ServiceProvider |
||||
| 11 | * |
||||
| 12 | * @package Spinen\QuickBooks |
||||
| 13 | */ |
||||
| 14 | class ServiceProvider extends LaravelServiceProvider |
||||
| 15 | { |
||||
| 16 | /** |
||||
| 17 | * Bootstrap the application services. |
||||
| 18 | * |
||||
| 19 | * @return void |
||||
| 20 | */ |
||||
| 21 | public function boot() |
||||
| 22 | { |
||||
| 23 | $this->registerMiddleware(); |
||||
| 24 | |||||
| 25 | $this->registerPublishes(); |
||||
| 26 | |||||
| 27 | $this->registerRoutes(); |
||||
| 28 | |||||
| 29 | $this->registerViews(); |
||||
| 30 | } |
||||
| 31 | |||||
| 32 | /** |
||||
| 33 | * Register the application services. |
||||
| 34 | * |
||||
| 35 | * @return void |
||||
| 36 | */ |
||||
| 37 | public function register() |
||||
| 38 | { |
||||
| 39 | $this->mergeConfigFrom(__DIR__ . '/../../config/quickbooks.php', 'quickbooks'); |
||||
| 40 | } |
||||
| 41 | |||||
| 42 | /** |
||||
| 43 | * Register the middleware |
||||
| 44 | * |
||||
| 45 | * If a route needs to have the QuickBooks client, then make sure that the user has linked their account. |
||||
| 46 | * |
||||
| 47 | */ |
||||
| 48 | public function registerMiddleware() |
||||
| 49 | { |
||||
| 50 | $this->app->router->aliasMiddleware('quickbooks', Filter::class); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 51 | } |
||||
| 52 | |||||
| 53 | /** |
||||
| 54 | * There are several resources that get published |
||||
| 55 | * |
||||
| 56 | * Only worry about telling the application about them if running in the console. |
||||
| 57 | * |
||||
| 58 | */ |
||||
| 59 | protected function registerPublishes() |
||||
| 60 | { |
||||
| 61 | if ($this->app->runningInConsole()) { |
||||
| 62 | $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); |
||||
| 63 | |||||
| 64 | $this->publishes([ |
||||
| 65 | __DIR__ . '/../../config/quickbooks.php' => config_path('quickbooks.php'), |
||||
|
0 ignored issues
–
show
The function
config_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 66 | ], 'quickbooks-config'); |
||||
| 67 | |||||
| 68 | $this->publishes([ |
||||
| 69 | __DIR__ . '/../../database/migrations' => database_path('migrations'), |
||||
|
0 ignored issues
–
show
The function
database_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 70 | ], 'quickbooks-migrations'); |
||||
| 71 | |||||
| 72 | $this->publishes([ |
||||
| 73 | __DIR__ . '/../../resources/views' => base_path('resources/views/vendor/quickbooks'), |
||||
|
0 ignored issues
–
show
The function
base_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 74 | ], 'quickbooks-views'); |
||||
| 75 | } |
||||
| 76 | } |
||||
| 77 | |||||
| 78 | /** |
||||
| 79 | * Register the routes needed for the registration flow |
||||
| 80 | */ |
||||
| 81 | protected function registerRoutes() |
||||
| 82 | { |
||||
| 83 | $config = $this->app->config->get('quickbooks.route'); |
||||
|
0 ignored issues
–
show
|
|||||
| 84 | |||||
| 85 | $this->app->router->prefix($config['prefix']) |
||||
|
0 ignored issues
–
show
|
|||||
| 86 | ->as('quickbooks.') |
||||
| 87 | ->middleware($config['middleware']['default']) |
||||
| 88 | ->namespace('Spinen\QuickBooks\Http\Controllers') |
||||
| 89 | ->group(function (Router $router) use ($config) { |
||||
| 90 | $router->get($config['paths']['connect'], 'Controller@connect') |
||||
| 91 | ->middleware($config['middleware']['authenticated']) |
||||
| 92 | ->name('connect'); |
||||
| 93 | |||||
| 94 | $router->delete($config['paths']['disconnect'], 'Controller@disconnect') |
||||
| 95 | ->middleware($config['middleware']['authenticated']) |
||||
| 96 | ->name('disconnect'); |
||||
| 97 | |||||
| 98 | $router->get($config['paths']['token'], 'Controller@token') |
||||
| 99 | ->name('token'); |
||||
| 100 | }); |
||||
| 101 | } |
||||
| 102 | |||||
| 103 | /** |
||||
| 104 | * Register the views |
||||
| 105 | */ |
||||
| 106 | protected function registerViews() |
||||
| 107 | { |
||||
| 108 | $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'quickbooks'); |
||||
| 109 | } |
||||
| 110 | } |
||||
| 111 |