Mã:
public function Store($data)
{
DB::beginTransaction();
try {
if(Users::Orderby('id', 'DESC')->first()) {
$userID = (int) User::Orderby('id', 'DESC')->first()->id + 1;
} else {
$userID = 1;
}
$profile =Profiles::create(['id' => $userID]);
$data = array_merge($data, ['interview_id' => $userID]);
$cv = Users::create($data);
DB::commit();
return true;
} catch (\Exception $e) {
return $e->getMessage();
} finally {
DB::disconnect();
}
}