本文整理汇总了PHP中App\Http\Controllers\DB::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::commit方法的具体用法?PHP DB::commit怎么用?PHP DB::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\DB
的用法示例。
在下文中一共展示了DB::commit方法的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']);
}
示例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');
}
}
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: 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();
}
}
示例8: 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();
}
}
示例9: 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;
}
}
示例10: 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();
}
}
示例11: 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);
}
}
示例12: 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();
}
}
示例13: store
public function store(Request $request)
{
$this->validate($request, ['app_name' => 'required|max:100']);
\DB::beginTransaction();
try {
$settings = Setting::find(1);
if (!empty($settings)) {
$settings->app_name = $request->app_name;
$settings->update();
} else {
$settings = new Setting();
$settings->app_name = $request->app_name;
$settings->save();
}
\DB::commit();
Session::flash('flash_message', 'Settings successfully updated!');
return redirect()->back();
} catch (Exception $e) {
DB::rollBack();
return redirect()->back();
}
}
示例14: product_submit
public function product_submit()
{
$data = \Request::input();
try {
\DB::beginTransaction();
$order = new Order();
$order->product_id = $data['product_id'];
$order->user_id = \Auth::user()->id;
$order->quantity = $data['item_count'];
$order->status = 'Inprogress';
$order->save();
// 견적서 메일 발송
//\Event::fire('order.send_mail', [$data]);
\DB::commit();
} catch (exception $e) {
\DB::rollback();
#return \Response::json(['result' => 'error']);
}
#return \Response::json(['result' => 'success']);
return \Redirect()->route('order_product', 1);
// 영업사원 user_id 로 변경 해야 함.
}
示例15: save
public function save(Request $request, $id = null)
{
if (!$this->user->isAdmin()) {
return redirect('crews');
}
\DB::beginTransaction();
$crew = Crew::findOrNew($id);
$crew->name = $request->input('name');
$crew->comments = $request->input('comments');
$crew->save();
// Save crew members.
\DB::table('crew_members')->where('crew_id', '=', $crew->id)->delete();
foreach (explode(',', $request->input('members')) as $member) {
$user = User::whereUsername($member)->first();
if ($user) {
$crewMember = new CrewMember();
$crewMember->user_id = $user->id;
$crewMember->crew_id = $crew->id;
$crewMember->save();
}
}
// Save availability dates.
\DB::table('crew_unavailabilities')->where('crew_id', '=', $crew->id)->delete();
foreach ($request->input('unavailabilities') as $unavail) {
if (empty($unavail['start_date']) && empty($unavail['end_date'])) {
continue;
}
$date = new \App\Model\CrewUnavailability();
$date->crew_id = $crew->id;
$date->start_date = $unavail['start_date'];
$date->end_date = $unavail['end_date'];
$date->save();
}
\DB::commit();
return redirect('crews');
}