Files
lucent-laravel/src/LucentServiceProvider.php
T

54 lines
1.4 KiB
PHP
Raw Normal View History

2023-10-02 23:10:49 +03:00
<?php
namespace Lucent;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\View;
2023-10-02 23:47:01 +03:00
use Illuminate\Support\ServiceProvider;
2023-10-02 23:10:49 +03:00
use Lucent\Channel\ChannelService;
use Lucent\Commands\CompileConfig;
use Lucent\Commands\RebuildThumbnails;
use Lucent\File\ImageService;
2023-10-02 23:47:01 +03:00
class LucentServiceProvider extends ServiceProvider
2023-10-02 23:10:49 +03:00
{
/**
* Register any application services.
*/
public function register(): void
{
$this->app->singleton(ChannelService::class, function () {
return ChannelService::fromConfig();
});
}
/**
* Bootstrap any package services.
*/
public function boot(Router $router): void
{
$router->aliasMiddleware('lucent.auth', \Lucent\Http\Middleware\AuthMiddleware::class);
$router->aliasMiddleware('lucent.guest', \Lucent\Http\Middleware\GuestMiddleware::class);
$this->loadViewsFrom(__DIR__ . '/Views', 'lucent');
$this->loadRoutesFrom(__DIR__ . '/Http/web.php');
$this->loadRoutesFrom(__DIR__ . '/Http/api.php');
if ($this->app->runningInConsole()) {
$this->commands([
CompileConfig::class,
RebuildThumbnails::class,
]);
}
View::share('image', app()->make(ImageService::class));
$this->publishes([
__DIR__ . '/Config/main.php' => config_path('lucent.php'),
]);
}
}