I am new to this try catch exception method so it will be helpful if you could provide detailed explanation of the answer to implement on the other files.
I am working on Laravel 5 and i want to use try catch while a put or post request is sent to the database. Below is my coding structure.
try{
$result = DB::table('myTable')
->where('uniqueTitle','=',$uniqueId)
->increment($field, 1);
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
My postman output is
QueryException in Connection.php line 669:
SQLSTATE[42S22]: Column not found: 1054 Unknown column
I have intentionally changed the column name to throw an error.
Additionally, how do i check on the required fields too with try and catch method.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire