php - Laravel Model Error Handling when Creating - Exception

PHOTO EMBED

Wed Aug 25 2021 16:19:17 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira #php

try {
    MFUser::create(array(
        'user_reference' => $this->userReference,
        'first_name' => $this->firstName,
        'last_name' => $this->lastName,
        'user_type_id' => $this->userTypeId,
        'email' => $this->email,
        'password' => $this->password
    ));
} catch (\Illuminate\Database\QueryException $exception) {
    // You can check get the details of the error using `errorInfo`:
    $errorInfo = $exception->errorInfo;

    // Return the response to the client..
}
content_copyCOPY

https://stackoverflow.com/questions/36241924/laravel-model-error-handling-when-creating