55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace LDC\WebAdminSecureLaravel;
|
||
|
|
|
||
|
|
use Illuminate\Console\Scheduling\Schedule;
|
||
|
|
use Illuminate\Support\ServiceProvider;
|
||
|
|
use Illuminate\Routing\Router;
|
||
|
|
use LDC\WebAdminSecureLaravel\Console\SyncFromLDCWeb;
|
||
|
|
use LDC\WebAdminSecureLaravel\Http\Middleware\AdminSecureMiddleware;
|
||
|
|
|
||
|
|
class AdminSecureServiceProvider extends ServiceProvider
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Bootstrap any application services.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function boot()
|
||
|
|
{
|
||
|
|
$this->publishes([
|
||
|
|
__DIR__ . '/../config' => config_path(),
|
||
|
|
], 'config');
|
||
|
|
|
||
|
|
// Register the command if we are using the application via the CLI .
|
||
|
|
if ($this->app->runningInConsole()) {
|
||
|
|
$this->commands([
|
||
|
|
SyncFromLDCWeb::class,
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
// * Cron Report everyday
|
||
|
|
$this->app->booted(function () {
|
||
|
|
/** @var \Illuminate\Console\Scheduling\Schedule */
|
||
|
|
$schedule = $this->app->make(Schedule::class);
|
||
|
|
$schedule->command('ldcweb:admin-secure-sync')->daily();
|
||
|
|
});
|
||
|
|
|
||
|
|
$router = $this->app->make(Router::class);
|
||
|
|
$router->aliasMiddleware('admin-secure', AdminSecureMiddleware::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Register any application services.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function register()
|
||
|
|
{
|
||
|
|
$this->mergeConfigFrom(
|
||
|
|
sprintf('%s/../config/admin-secure.php', __DIR__),
|
||
|
|
'admin-secure'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|