If the $request->SN
is either invalid or empty, I get an error like the following.
Trying to get property of non-object
Ticket::create([
'user_id' => Laptop::where('SN', $request->SN)->first()->user_id,
'laptop_id' => Laptop::where('SN', $request->SN)->first()->id,
'title' => $request->title,
'body' => $request->body,
'laptop_ww' => $request->laptop_ww
]);
How can I display a custom error instead of this exception? By default, it goes to an error page with status 500.