コード例 #1
0
 public function checkOff($id)
 {
     $item = ShoppingList::find($id);
     $item->checked = true;
     $item->save();
     return ['ok'];
 }
コード例 #2
0
 /**
  * Shows list page.
  *
  * @param $id, the id of the list
  * @return Response, a view for showing a specific list page.
  */
 public function getList($date)
 {
     $res = DB::table('daylist')->where('day', '=', $date)->get();
     $lists = $listIDs = [];
     foreach ($res as $r) {
         $list = ShoppingList::find($r->list);
         $listIDs[] = $r->list;
         $lists[] = $list;
         $list->products()->orderBy('status')->orderBy('name')->get();
     }
     $products = Product::whereIn('list', $listIDs)->orderBy('status')->orderBy('name')->get();
     return view('shop.list')->with('date', $date)->with('lists', $lists)->with('products', $products);
 }
コード例 #3
0
 public function getShow($id)
 {
     $list = ShoppingList::find($id);
     $products = $list->products()->orderBy('status')->orderBy('name')->get();
     return response()->json($products);
 }
コード例 #4
0
 public function postSettings(Request $request)
 {
     $list = ShoppingList::find($request->input('id'));
     $list->budget = $request->input('budget');
     $list->name = $request->input('name');
     $list->eventdate = $request->input('eventdate');
     $list->save();
     return redirect('list/show/' . $list->id)->with('success', 'Listan uppdaterades.');
 }