本文整理汇总了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');
}
示例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()));
}
}
示例3: deleteInvoice
public function deleteInvoice($id)
{
Invoice::findOrFail($id)->delete();
return Redirect::intended('admin/invoice');
}
示例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');
}
示例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'));
}
}