<?php

namespace Aura\Forms;

use Aura\Forms\Http\Livewire\ActionsField;
use Aura\Forms\Http\Livewire\EditQuestion;
use Aura\Forms\Http\Livewire\QuestionsField;
use Aura\Forms\Http\Livewire\ViewForm;
use Eminiarts\Aura\Facades\Aura;
use Livewire\Livewire;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class FormsServiceProvider 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('forms')
            ->hasConfigFile()
            ->hasViews()
            ->hasRoutes('web')
            ->hasMigration('create_forms_table');

        Aura::registerResources([
            \Aura\Forms\Resources\Form::class,
            \Aura\Forms\Resources\Submission::class,
        ]);
    }

    public function packageBooted()
    {
        Livewire::component('forms::questions-field', QuestionsField::class);
        Livewire::component('forms::actions-field', ActionsField::class);
        Livewire::component('forms::edit-question', EditQuestion::class);

        Livewire::component('forms::view-form', ViewForm::class);
    }
}
