Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $order = new Order();
     $order->setTotal($request->input('total'));
     $order->save();
     foreach ($request->input('sweeties') as $sweetyId) {
         $order->sweeties()->attach(Sweety::findOrFail($sweetyId));
     }
     $order->save();
     return JsonResponse::create($order->load('sweeties'));
 }
Ejemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show(\App\Order $order)
 {
     if ($order->client_id == \Auth::user()->id) {
         return $order->load('waiter');
     }
 }