本文整理汇总了PHP中Item::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::destroy方法的具体用法?PHP Item::destroy怎么用?PHP Item::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::destroy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public static function destroy($id)
{
self::check_logged_in();
$item = new Item(array('id' => $id));
$item->destroy();
Redirect::to('/item', array('message' => 'The item has been removed successfully!'));
}
示例2: getDelete
public function getDelete($item_id)
{
$message = "エラーが発生しました。";
if (Item::find($item_id)) {
Item::destroy($item_id);
Review::where('item_id', '=', $item_id)->delete();
$message = "レビュー対象を削除しました。";
}
Session::flash('alert', $message);
return Redirect::to('/review');
}
示例3: destroy
/**
* Remove the specified item from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Item::destroy($id);
return Redirect::route('items.index');
}
示例4: destroy
/**
* Remove the specified resource from storage.
* DELETE /items/{id}
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$status = Item::destroy($id);
return $status ? ['status' => true] : ['status' => false];
}
示例5: removeItem
public function removeItem($id)
{
Item::destroy($id);
return redirect('/shop');
}
示例6:
<?php
require_once '../classes/session.php';
require __DIR__ . '/../vendor/autoload.php';
require_once '../classes/Restaurant.php';
require_once '../classes/Item.php';
require '../config.php';
require '../classes/boot.php';
$item_id = $_GET['item_id'];
$rest_id = $_GET['rest_id'];
Item::destroy($item_id);
header("location:view_items.php?id={$rest_id}");
示例7: destroy
/**
* Remove the specified item from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Item::destroy($id);
return Redirect::route('items.index')->withDeleteMessage('Item successfully deleted!');
}
示例8: 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'));
}
}