예제 #1
0
 /**
  * 
  * Store - Processes $_POSTs from the Add Item page
  * Parameter - CreateItemRequest
  */
 public function store(Requests\CreateItemRequest $request)
 {
     $input = $request->all();
     $input['user_id'] = Auth::id();
     Item::create($input);
     return redirect('items');
 }
예제 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\CreateItemRequest $request)
 {
     //
     $user = Auth::User();
     if ($request->has('id')) {
         // is an update.
     } else {
         $item = new Item($request->all());
         $item = $user->items()->save($item);
         //populate relation
         $item->client;
     }
     return response()->json(['result' => 'success', 'item' => $item], 200);
 }
 public function store(Requests\CreateItemRequest $request)
 {
     $product = new Item();
     $product->item_name = $request->get('item_name');
     $product->category = $request->get('category');
     $product->expiry_date = $request->get('expiry_date');
     $product->search_key = $request->get('search_key');
     $product->quantity = $request->get('quantity');
     $product->unit_price = $request->get('unit_price');
     $product->shops_shop_id = $request->shop_id;
     $product->unit = $request->unit;
     // $product->picture = $request::get('picture');
     if ($request->hasFile('profilePicFile')) {
         $file = Input::file('profilePicFile');
         $name = $request->shop_id . '-' . $product->item_name . $file->getClientOriginalName();
         $product->picture = $name;
         $file->move(public_path() . '/images/' . $product->category . '/', $name);
     }
     $product->discount = $request->get('discount');
     $product->product_code = $request->get('product_code');
     $product->state = $request->get('state');
     $product->description = $request->get('description');
     // $data['country'] = Product::getCountryOptions();
     //Auth::user()->Items()->save($product);
     \Session::flash('success', 'Product successfully added!');
     $product->save();
     return \Redirect::back();
     //->with($data);
 }