Пример #1
1
 public function store(ItemRequest $request)
 {
     try {
         $customers = Customer::all();
         Item::create($request->all());
         $item = Item::orderBy('created_at', 'desc')->first();
         foreach ($customers as $customer) {
             Price::create(['item_id' => $item->id, 'customer_id' => $customer->id, 'custom_price' => $item->price, 'sellable' => '1', 'is_custom' => '0']);
         }
         return redirect('item')->with('message', 'Data berhasil dibuat!');
     } catch (\Illuminate\Database\QueryException $e) {
         return redirect('item')->with('message', 'Data dengan nama tersebut sudah digunakan!');
     } catch (\PDOException $e) {
         return redirect('item')->with('message', 'Data dengan nama tersebut sudah digunakan!');
     }
 }
Пример #2
0
 public function getExample1()
 {
     //Order by amount
     $items = \App\Item::orderBy('amount', 'asc')->get();
     dump($items->toArray());
     foreach ($items as $item) {
         echo $item->name;
     }
     return 'Example 1';
 }
Пример #3
0
 public function add(Request $request)
 {
     //Get max item order id and add 1
     $order = Item::orderBy('item_order', 'desc')->pluck('item_order');
     $order++;
     $item = new Item();
     $item->title = $request->input('entry');
     $item->item_order = $order;
     $item->save();
     $returnId = $item->id;
     return array("id" => $returnId);
 }
Пример #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $userid = Auth::id();
     $items = Item::orderBy('item_name', 'asc')->get();
     $editInput = Item::findOrFail($id);
     $skuscan = null;
     $email = User::where('id', $userid)->first()->email;
     $scan = Scan::where('userEmail', $email)->first();
     if ($scan) {
         $skuscan = $scan;
     }
     $totalValue = Item::where('user', $userid)->sum('price');
     $totalQuantity = Item::where('user', $userid)->sum('quantity');
     return view('inventory', compact('items', 'editInput', 'totalValue', 'totalQuantity', 'skuscan'));
 }
Пример #5
0
<?php

use App\Item;
$app->get('/', function () use($app) {
    $items = Item::orderBy('item_order', 'asc')->get();
    return view('index', ['items' => $items]);
});
$app->post('/add-item', 'App\\Http\\Controllers\\ItemController@add');
$app->post('/edit-item', 'App\\Http\\Controllers\\ItemController@edit');
$app->post('/delete-item', 'App\\Http\\Controllers\\ItemController@delete');
$app->post('/sort-items', 'App\\Http\\Controllers\\ItemController@sort');
Пример #6
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $items = App\Item::orderBy('name')->get();
     return $items;
 }
 public function index()
 {
     $items = Item::orderBy('id', 'DESC')->paginate(10);
     return view('item.index', compact('items'));
 }