summaryrefslogtreecommitdiff
path: root/src/ServiceProvider.php
blob: 1128218f55c5b0a5cfeb79f2e147be2dd2cb5491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

namespace Lightscale\LaralightTables;

use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Support\ServiceProvider as ServiceProviderBase;
use Lightscale\LaralightAssets\Facades\Assets;

class ServiceProvider extends ServiceProviderBase
{
    public function register(): void {}

    public function boot(): void
    {
        AboutCommand::add('Laralight Tables', fn () => [
            'Version' => 'dev',
        ]);

        $ns = Service::NAMESPACE;
        $root = __DIR__.'/..';
        $viewsPath = "{$root}/resources/views";
        $assetsUri = "vendor/{$ns}";
        $assetsPath = public_path($assetsUri);

        $this->loadViewsFrom($viewsPath, $ns);

        $this->publishes([
            $viewsPath => resource_path("views/vendor/{$ns}"),
        ], Service::NAMESPACE.'-views');

        $this->publishes([
            "{$root}/public" => $assetsPath,
        ], "{$ns}-assets");

        Assets::registerManifest($ns, "{$assetsPath}/assets-manifest.json", $assetsUri);
    }
}