I am trying to determine when inserting a record using eloquence in Laravel when it throws an exception due to a unique field error.
The code I have so far is:
try { $result = Emailreminder::create(array( 'user_id' => Auth::user()->id, 'email' => $newEmail, 'token' => $token, )); } catch (Illuminate\Database\QueryException $e) { return $e; }
It throws an exception. OK. I just don't know what to do to identify it as a duplicate column error.
Thanks,
Gavin.
Gavin source share