Answers for "try/catch --> much needed"

PHP
0

try/catch --> much needed

public function sendContactForm(SendContactFormRequest $request)
{
    try {
        $data = [
            'name' => $request->get('name'),
            'email' => $request->get('email'),
            'phone' => $request->get('phone'),
            'message' => $request->get('message'),
        ];
        // SEND EMAIL
        $this->sendNotification($data);

        return redirect()
            ->back()
            ->with('success', trans('web.'));

    } catch (Exception $e) {
        return redirect()
            ->back()
            ->with('danger', $e->getMessage());
    }
}
Posted by: Guest on March-31-2022

Browse Popular Code Answers by Language