belongsTo('App\Models\Login\AccountInfo', 'AccountDBID'); } public static function SaveHistory($AccountDBID, $LinkItemID, $Count, $Price) { // Inicia as transactions $history_tran = DB::connection('WEB'); $history_tran->beginTransaction(); try { $hitory = new HistoryShopBuyedItem; $hitory->AccountDBID = $AccountDBID; $hitory->LinkItemID = $LinkItemID; $hitory->Count = $Count; $hitory->Price = $Price; $hitory->Created_At = now(); $hitory->save(); // COMMIT TRAN $history_tran->commit(); } catch (\Exception $e){ // ROLLBACK $history_tran->rollback(); throw new \Exception($e); } } }