I have a query of type Insert
and I need to know if that query succeeded to perform a following query.
DB::table('fichas_medicas')
->insert(['Paciente_ID' => $user_data->ID,
'Medico_ID' => $request->medico,
'Centromedico_ID' => 1,
'fecha'=>$fecha,
'hora'=>$hora,
'nro'=>1,
'turno'=>'morning',
'estado'=>'waiting'
]);
This is my query... I need to know if the query was made in order to then perform a update
from another table.
I'm working with Laravel's QueryBuilder, I'm not using Eloquent
Good day,
I can think of a couple of ways to detect if the QueryBuilder completed its task
Try&Catch
Assign the query result to a variable
Try & Catch is a common method to process errors or detect if an action completes successfully. I would recommend this option