anaseqal / nova-import

Laravel Nova Import Action
72 stars 28 forks source link

Display validation errors #28

Open mariuscirstea opened 3 years ago

mariuscirstea commented 3 years ago

How can we display validation errors inside Nova?

hanafiah commented 3 years ago

you can try..catch at handle() method for example

public function handle(ActionFields $fields, Collection $models)
    {
        try {
            Excel::import(new TicketsImport, $fields->file);
            return Action::message('Tickets Succesfully Imported!');
        } catch (\Maatwebsite\Excel\Validators\ValidationException $e) {
            return Action::danger($e->errors());
        }

    }