<?php

namespace App\Http\Controllers\Administracion\Crud\Entidades;

use App\Http\Controllers\Administracion\Crud\BaseCrudController;
use App\Services\Administracion\Crud\PreciosPorBienCrudService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;

class PreciosPorBienCrudController extends BaseCrudController
{
    public function __construct(PreciosPorBienCrudService $crudService)
    {
        parent::__construct($crudService);
    }

    public function storeBulk(Request $request): RedirectResponse
    {
        /** @var PreciosPorBienCrudService $crudService */
        $crudService = $this->crudService;

        return $crudService->storeBulk($request);
    }

    public function bulkForm(): View|RedirectResponse
    {
        if ($redirect = $this->crudService->guardWritableRedirect()) {
            return $redirect;
        }

        /** @var PreciosPorBienCrudService $crudService */
        $crudService = $this->crudService;

        return view('administracion.crud.entities.precios-por-bien.bulk-form', $crudService->buildBulkFormData());
    }
}