Пример #1
0
 function update_sales_reps()
 {
     if (!isset($this->params['id'])) {
         flashAndFlow('error', 'Unable to process request. Invalid order number.');
         //expHistory::back();
     }
     $order = new order($this->params['id']);
     $order->sales_rep_1_id = $this->params['sales_rep_1_id'];
     $order->sales_rep_2_id = $this->params['sales_rep_2_id'];
     $order->sales_rep_3_id = $this->params['sales_rep_3_id'];
     $order->save();
     flashAndFlow('message', 'Sales reps updated.');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('spares_id' => 'required');
     foreach (Input::get('quantity') as $key => $val) {
         $rules['quantity.' . $key] = 'required|numeric';
     }
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('order/create')->withErrors($validator)->withInput(Input::except('quantity'));
     } else {
         // store
         $order = new order();
         $order->save();
         $id = $order->id;
         $quantity = Input::get('quantity');
         $spares_id = Input::get('spares_id');
         foreach ($quantity as $key => $val) {
             $item = new Item();
             $item->spares_id = $spares_id[$key];
             $item->quantity = $quantity[$key];
             $item->order_id = $id;
             //$Order->note = Input::get('note');
             echo $item->save();
         }
         Session::flash('message', 'Successfully created Order!');
         return Redirect::to('order');
     }
 }