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


PHP Invoice::findOrFail方法代码示例

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


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

示例1: update

 /**
  * Update the specified invoice in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id)
 {
     $invoice = Invoice::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $invoice->update($data);
     return Redirect::route('invoices.index');
 }
开发者ID:tharindarodrigo,项目名称:agent,代码行数:16,代码来源:InvoicesController.php

示例2: update

 /**
  * Update the specified product in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $invoice = Invoice::findOrFail($id);
     $validator = Validator::make(Input::all(), Invoice::$rules);
     if ($validator->passes()) {
         $invoice->update(Input::all());
         return Response::json(array('success' => true, 'message' => 'Cập nhật phiếu thu chi thành công!'));
     } else {
         return Response::json(array('success' => false, 'errors' => $validator->errors()));
     }
 }
开发者ID:jimmyhien,项目名称:dailyhuuhoc,代码行数:17,代码来源:InvoicesController.php

示例3: deleteInvoice

 public function deleteInvoice($id)
 {
     Invoice::findOrFail($id)->delete();
     return Redirect::intended('admin/invoice');
 }
开发者ID:jeremiteki,项目名称:mteja,代码行数:5,代码来源:HousController.php

示例4: update

 /**
  * Update the specified quote in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     if (!Sentry::getUser()) {
         return Redirect::route('sessions.create');
     }
     $quote = Invoice::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $quote->update($data);
     return Redirect::route('invoices.index');
 }
开发者ID:dynamicsystems,项目名称:TechTracker,代码行数:19,代码来源:InvoicesController.php

示例5: update

 /**
  * Update the specified resource in storage.
  * PUT /invoices/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $user = Auth::user();
     $invoice = Invoice::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $invoice->biller_id = Input::get('biller_id');
     $invoice->client_id = Input::get('client_id');
     $invoice->currency_id = Input::get('currency_id');
     $invoice->number = Input::get('number');
     $invoice->subtotal = floatval(Input::get('subtotal'));
     $invoice->tax_rate_id = Input::get('tax_rate');
     $invoice->tax_total = floatval(Input::get('invoice_total_tax'));
     $invoice->total = floatval(Input::get('total'));
     $invoice->paid = floatval(Input::get('invoice_total_paid'));
     $invoice->balance = $invoice->total - $invoice->paid;
     $invoice->user_id = $user->id;
     if (Input::has('date')) {
         $invoice->date = Input::get('date');
     }
     if (Input::has('due_date')) {
         $invoice->due_date = Input::get('due_date');
     }
     $invoice->note = Input::get('note');
     if ($invoice->save()) {
         $item_id = Input::get('item_id');
         $name = Input::get('item_name');
         $description = Input::get('item_description');
         $price = Input::get('item_price');
         $quantity = Input::get('item_qty');
         $old_items = $invoice->item->lists('id');
         $diff = array_diff($old_items, $item_id);
         if (!empty($diff)) {
             Item::destroy($diff);
         }
         $keys = array('item_id', 'name', 'description', 'price', 'quantity');
         $items = array();
         foreach (array_map(null, $item_id, $name, $description, $price, $quantity) as $key => $value) {
             $items[] = array_combine($keys, $value);
         }
         foreach ($items as $item) {
             $itemRecord = array('invoice_id' => $invoice->id, 'name' => $item['name'], 'description' => $item['description'], 'price' => floatval($item['price']), 'quantity' => floatval($item['quantity']), 'total' => floatval($item['price']) * floatval($item['quantity']));
             if (empty($item['item_id'])) {
                 $item = Item::create($itemRecord);
                 //$invoice->item()->create($itemRecord);
             } else {
                 // print($item['item_id']);
                 $item = Item::where('id', '=', $item['item_id'])->update($itemRecord);
                 //$invoice->item()->update($itemRecord);
             }
         }
         return Redirect::to('invoices/' . $invoice->id . '/edit')->with('success', Lang::get('invoices.message.success.update'));
     }
 }
开发者ID:mladjom,项目名称:smartinvoice,代码行数:63,代码来源:InvoicesController.php


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