Have a method to import CSV data into a database. I do some basic checks using
class CsvImportController extends Controller
{
public function import(Request $request)
{
$this->validate($request, [
'csv_file' => 'required|mimes:csv,txt',
]);
But after that, things can go wrong for more complex reasons, further down the rabbit hole, which raises exceptions. I can’t write the correct verification material that will be used here using the method validate, but I really like how Laravel works when the verification fails, and how easy it is to embed errors (errors) in the blade view, etc., so ...
Is there a (preferably clean) way to manually tell Laravel that “I know that I haven't used your method validateright now, but I would really like you to find this error here as if I did”? Is there something that I can return, an exception that I can wrap, or something else?
try
{
}
catch(\Exception $e)
{
}
source
share