<?php

namespace Aura\Pro;

use Aura\Base\Facades\Aura;
use Aura\Pro\Commands\ProCommand;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Blade;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class ProServiceProvider extends PackageServiceProvider
{
    public function configurePackage(Package $package): void
    {
        /*
         * This class is a Package Service Provider
         *
         * More info: https://github.com/spatie/laravel-package-tools
         */
        $package
            ->name('pro')
            ->hasConfigFile()
            ->hasViews()
            // ->hasMigration('create_pro_table')
            ->hasCommand(ProCommand::class);
    }

    public function packageBooted()
    {
        // inject view
        app('aura')::registerInjectView('table_before', fn (): View => view('pro::table.table_before'));

        // ray('packageBooted pro service provider');

        // Blade Example
        // Aura::registerInjectView('table_before', fn (): string => Blade::render('@livewire(\'livewire-ui-modal\')'));
    }

    public function packageRegistered()
    {
        // dd('registered');
        $this->app->bind(\Aura\Base\Livewire\Table\Table::class, \Aura\Pro\Http\Livewire\Table\Table::class);
    }
}
