Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

knubbe's avatar
Level 36

Validation with laravel nova custom tool

I have some form in custom laravel nova tool and I am not sure how can I handle and show validation error messages.

In Tool.vue I have a method for handling form which is look something like this:

createInvoice() {
    Nova.request().post('/nova-vendor/invoice-creation', this.form)
    ...
},

In api.php I have basic thing:

Route::post('/', \App\Http\Controllers\CreateInvoiceController::class);

and my controller looks like this:

class CreateInvoiceController extends Controller
{
    public function __invoke(StoreInvoice $request)
    {
        $data = $request->validated();
        $invoiceData = Arr::except($data, 'items');
        $servicesData = collect(Arr::only($data, 'items'))->flatten(1)->toArray();

        /** @var Invoice $invoice */
        $invoice = Invoice::create($invoiceData);

        $invoice->services()->createMany($servicesData);
    }
}

What should I return from controller and how to pass validation errors and handle that on client side?

0 likes
0 replies

Please or to participate in this conversation.