/**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     //return $request['branchId'];
     $login = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first();
     $stock = Stock::where('stockTypeId', $request['stockTypeId'])->where('branchId', $request['branchId'])->where('productTypeId', $request['productTypeId'])->first();
     if (count($stock)) {
         $stockProduct = new AddProduct();
         $stockProduct->stockId = $stock->id;
         $stockProduct->quantity = $request['onlineQuantity'];
         $stockProduct->addedBy = $login->member_id;
         $stockProduct->added = 1;
         $stockProduct->save();
         $returnData = array('status' => 'added', 'stock' => $stock, 'stockProduct' => $stockProduct, 'code' => 200);
         return Response::json($returnData, 200);
     } else {
         try {
             $stock = new Stock();
             $stock->fill(Input::all());
             $stock->addedBy = $login->member_id;
             $stock->save();
             $stockProduct = new AddProduct();
             $stockProduct->stockId = $stock->id;
             $stockProduct->quantity = $request['onlineQuantity'];
             $stockProduct->addedBy = $login->member_id;
             $stockProduct->added = 1;
             $stockProduct->save();
             $stock->quantity = $request['onlineQuantity'];
             $returnData = array('status' => 'created', 'stockProduct' => $stockProduct, 'stock' => $stock, 'code' => 200);
             return Response::json($returnData, 200);
         } catch (\Exception $e) {
             return $e->getMessage();
         }
     }
 }