当前位置: 首页>>代码示例>>PHP>>正文


PHP DB::beginTransaction方法代码示例

本文整理汇总了PHP中App\Http\Controllers\DB::beginTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::beginTransaction方法的具体用法?PHP DB::beginTransaction怎么用?PHP DB::beginTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Controllers\DB的用法示例。


在下文中一共展示了DB::beginTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: destory

 public function destory()
 {
     try {
         \DB::beginTransaction();
         $product = Product::find(\Request::get('product_id'));
         $product->status = 'STOP';
         $product->save();
         \DB::commit();
     } catch (exception $e) {
         \DB::rollback();
         return \Response::json(['result' => 'success']);
     }
     return \Response::json(['result' => 'success']);
 }
开发者ID:comsi02,项目名称:ordermart,代码行数:14,代码来源:ProductController.php

示例2: getCheckuser

 public function getCheckuser()
 {
     $sessionfb = Session::get('sessionfb');
     dd($sessionfb);
     $userfb = Session::get('userfb');
     $check = User::checkuser($userfb, $nh);
     //kiem tra id nha hang
     //kiem tra check, neu khong co nguoi dung trong db
     if ($check == false) {
         if (!NhaHang::checkid($nh)) {
             return Redirect::to('/error');
         } else {
             DB::beginTransaction();
             try {
                 $user = User::createuser($userfb, htmlentities($_SERVER['HTTP_USER_AGENT']), $nh);
                 $code = Code::createcode($userfb, $type, $nh);
                 DB::commit();
             } catch (Exception $e) {
                 //If there are any exceptions, rollback the transaction
                 DB::rollback();
             }
             //Everything worked perfectly. Commit the transaction
             $user = $userfb->asArray();
             $user['fb_id'] = $user['id'];
             Session::put('user', (object) $user);
             return Redirect::to('/hello');
         }
     } else {
         $user = $check;
         $user->save();
         $c = false;
         $arrs = Code::where('fb_id', $user->fb_id)->get();
         foreach ($arrs as $arr) {
             if ($nh == $arr->nhahang_id) {
                 $c = true;
                 break;
             }
         }
         if (!$c) {
             $code = Code::createcode($userfb, $type, $nh);
             Session::put('user', $user);
             return Redirect::to('/hello');
         } else {
             Session::put('user', $user);
             return Redirect::to('/hello');
         }
     }
 }
开发者ID:NhuanTDBK,项目名称:Bluemix-Laravel-Demo,代码行数:48,代码来源:FaceBookController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['prompt' => 'required|max:100|unique_with:forms, formgroup = form_group_id, formtype = form_type_id', 'formgroup' => 'required|not_in:0', 'formtype' => 'required|not_in:0']);
     \DB::beginTransaction();
     try {
         $form = new Form();
         $form->form_group_id = $request->formgroup;
         $form->form_type_id = $request->formtype;
         $form->prompt = $request->prompt;
         $form->required = $request->required == '1' ? 1 : 0;
         $form->expected_answer = $request->expected_answer == '1' ? 1 : 0;
         $form->exempt = $request->exempt == '1' ? 1 : 0;
         $form->save();
         if ($request->formtype == 9) {
             $multiData = array();
             foreach ($request->multiselect as $option) {
                 $multiData[] = array('form_id' => $form->id, 'multi_select_id' => $option);
             }
             if (count($multiData) > 0) {
                 FormMultiSelect::insert($multiData);
             }
         }
         if ($request->formtype == 10) {
             $singleData = array();
             foreach ($request->singleselect as $option) {
                 $singleData[] = array('form_id' => $form->id, 'single_select_id' => $option);
             }
             if (count($singleData) > 0) {
                 FormSingleSelect::insert($singleData);
             }
         }
         if ($request->formtype == 11) {
             if ($request->has('formula')) {
                 $formformula = new FormFormula();
                 $formformula->form_id = $form->id;
                 $formformula->formula = $request->formula;
                 $formformula->save();
             }
         }
         \DB::commit();
         Session::flash('flash_message', 'Form successfully added!');
         return redirect()->route("form.index");
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:53,代码来源:FormsController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['distributor' => 'required|max:100|unique_with:distributors, distributor_code = distributor_code', 'distributor_code' => 'required|not_in:0']);
     \DB::beginTransaction();
     try {
         $distributor = new Distributor();
         $distributor->distributor_code = $request->distributor_code;
         $distributor->distributor = $request->distributor;
         $distributor->save();
         \DB::commit();
         Session::flash('flash_message', 'Distributor successfully added!');
         return redirect()->route("distributor.index");
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:23,代码来源:DistributorController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $matrix = GradeMatrix::findOrFail($id);
     $this->validate($request, ['desc' => 'required|max:100|unique_with:grade_matrixs, passing = passing,' . $id, 'passing' => 'required|not_in:0']);
     \DB::beginTransaction();
     try {
         $matrix->desc = $request->desc;
         $matrix->passing = $request->passing;
         $matrix->update();
         \DB::commit();
         Session::flash('flash_message', 'Grade Matrix successfully updated!');
         return redirect()->route("gradematrix.edit", [$id]);
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:24,代码来源:GradeMatrixController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\AddTask $request)
 {
     try {
         \DB::beginTransaction();
         $task = new Task();
         $task->fill($request->only('title', 'description', 'deadline'));
         $task->user_id = auth()->user()->id;
         $task->save();
         \DB::commit();
         flash()->success('Task added to list successfully.');
         return redirect()->back();
     } catch (\Exception $e) {
         \DB::rollback();
         flash()->error($e->getMessage());
         return redirect()->back()->withInput();
     }
 }
开发者ID:git-mahfuz,项目名称:task-completion-rate,代码行数:23,代码来源:TaskController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['region' => 'required|max:100|unique_with:regions, region_code = region_code', 'region_code' => 'required|not_in:0']);
     \DB::beginTransaction();
     try {
         $region = new Region();
         $region->region_code = $request->region_code;
         $region->region = $request->region;
         $region->save();
         \DB::commit();
         Session::flash('flash_message', 'Region successfully added!');
         return redirect()->route("region.index");
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:23,代码来源:RegionController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['area' => 'required|max:100|unique_with:areas, customer = customer_id', 'customer' => 'required|not_in:0']);
     \DB::beginTransaction();
     try {
         $area = new Area();
         $area->customer_id = $request->customer;
         $area->area = $request->area;
         $area->save();
         \DB::commit();
         Session::flash('flash_message', 'Area successfully added!');
         return redirect()->route("area.index");
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:23,代码来源:AreaController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['brand' => 'required|max:100|unique_with:secondary_displays, category = category_id', 'category' => 'required|not_in:0']);
     \DB::beginTransaction();
     try {
         $display = new SecondaryDisplay();
         $display->category_id = $request->category;
         $display->brand = $request->brand;
         $display->save();
         \DB::commit();
         Session::flash('flash_message', 'Secondary Display successfully added!');
         return redirect()->route("secondarydisplay.index");
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:23,代码来源:SecondarydisplayController.php

示例10: restoreStockForProduct

 public function restoreStockForProduct(Request $request)
 {
     $purchaseOrderId = $request->input('purchase_order_id');
     $productId = $request->input('product_id');
     try {
         \DB::beginTransaction();
         // First restore the stock levels for the product deleted from the PO
         $this->workOrderSchedulerService->restoreStockForProducts($purchaseOrderId, $productId);
         // Now delete any workorders for this product generated by the PO
         $this->workOrderSchedulerService->deleteWorkOrdersForPo($purchaseOrderId, $productId);
         // Finally delete the actual purchaseOrderProduct row
         $this->workOrderSchedulerService->deletePurchaseOrderProduct($purchaseOrderId, $productId);
         \DB::commit();
     } catch (\Exception $ex) {
         \DB::rollBack();
         throw $ex;
     }
 }
开发者ID:breenyoung,项目名称:wfadmin,代码行数:18,代码来源:SchedulerController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['customer' => 'required|max:100|unique_with:customers, customer_code = customer_code, account = account_id', 'customer_code' => 'required|not_in:0', 'account' => 'required|not_in:0']);
     \DB::beginTransaction();
     try {
         $customer = new Customer();
         $customer->account_id = $request->account;
         $customer->customer_code = $request->customer_code;
         $customer->customer = $request->customer;
         $customer->save();
         \DB::commit();
         Session::flash('flash_message', 'Customer successfully added!');
         return redirect()->route("customer.index");
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:24,代码来源:CustomerController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:100']);
     \DB::beginTransaction();
     try {
         $role = new Role();
         $role->name = $request->name;
         $role->display_name = $request->display_name;
         $role->description = $request->description;
         $role->save();
         \DB::commit();
         Session::flash('flash_message', 'Role successfully added!');
         return redirect()->route("role.index");
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:24,代码来源:RoleController.php

示例13: update

 public function update($id)
 {
     try {
         \DB::beginTransaction();
         $userObject = \App\Models\User::find($id);
         if (empty($userObject)) {
             return \Redirect::back()->withErrors('Unable to update the password');
         }
         $data = \Input::all();
         if (!empty($userObject->password)) {
             if (empty($data['old_password']) || empty($data['new_password']) || empty($data['re_type_password'])) {
                 return \Redirect::back()->withErrors('All Three Fields are required');
             }
             $old_password = $data['old_password'];
         } else {
             if (empty($data['new_password']) || empty($data['re_type_password'])) {
                 return \Redirect::back()->withErrors('Both Fields are required');
             }
         }
         $new_password = $data['new_password'];
         $re_type_password = $data['re_type_password'];
         if ($new_password != $re_type_password) {
             return \Redirect::back()->withErrors('Passwords do not match');
         }
         if (!empty($old_password)) {
             if ($old_password == $re_type_password) {
                 return \Redirect::back()->withErrors('New password and current password are same');
             }
             if (!\Hash::check($old_password, $userObject->password)) {
                 return \Redirect::back()->withErrors('Incorrect Old Password');
             }
         }
         $userObject->password = bcrypt($new_password);
         if (!$userObject->save()) {
             $errors = $userObject->getErrors();
             return Redirect::back()->withErrors($errors);
         }
         \DB::commit();
         \Flash::success('Login password updated successfully');
         return redirect(url('/account/password'));
     } catch (\Exception $e) {
         abort(500);
     }
 }
开发者ID:prathyushasahusoft,项目名称:Angular-Scripts,代码行数:44,代码来源:ChangePasswordController.php

示例14: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $user = User::findorFail($id);
     $this->validate($request, ['name' => 'required|max:100', 'email' => 'required|max:100|email', 'username' => 'required|max:100']);
     \DB::beginTransaction();
     try {
         $user->name = strtoupper($request->name);
         $user->email = strtolower($request->email);
         $user->username = $request->username;
         $user->active = $request->active ? 1 : 0;
         $user->update();
         \DB::commit();
         Session::flash('flash_message', 'User successfully updated!');
         return redirect()->route("user.edit", [$id]);
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:26,代码来源:UserController.php

示例15: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $category = FormCategory::findOrFail($id);
     $this->validate($request, ['category' => 'required|max:100|unique_with:form_categories,' . $id]);
     \DB::beginTransaction();
     try {
         $category->category = $request->category;
         $category->secondary_display = $request->secondary_display ? 1 : 0;
         $category->osa_tagging = $request->osa_tagging ? 1 : 0;
         $category->sos_tagging = $request->sos_tagging ? 1 : 0;
         $category->custom = $request->custom ? 1 : 0;
         $category->perfect_store = $request->perfect_store ? 1 : 0;
         $category->update();
         \DB::commit();
         Session::flash('flash_message', 'Form Catagory successfully updated!');
         return redirect()->route("formcategory.edit", [$id]);
     } catch (Exception $e) {
         DB::rollBack();
         return redirect()->back();
     }
 }
开发者ID:renciebautista,项目名称:perfectstore,代码行数:28,代码来源:FormCategoryController.php


注:本文中的App\Http\Controllers\DB::beginTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。