public function induct(Product $item, User $user, $quantity, $details)
 {
     $start_quantity = $item->quantity;
     $item->quantity = $item->quantity + $quantity;
     if ($result = $item->save()) {
         Helper::log('induct', 'deposit', $user, 'EPR', 'quantity', $quantity, $item->id, $quantity, $start_quantity, $item->quantity, get_class($item), $details);
     }
     return $result;
 }
示例#2
0
 public function recipe(Request $r)
 {
     if ($r->has('product_id')) {
         $p = Product::find($r->get('product_id'));
         $recipe = $p->recipe;
         $i = Ingredient::where('recipe_id', '=', $recipe->first()->id)->get();
         return ['recipe' => $p->recipe, 'ingredient' => $i->lists('quantity', 'name')];
     }
 }
示例#3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $extension = "png";
     $product = Product::find($input['product_id']);
     if ($product) {
         $file = $this->BgcOutput->output($request->get('barcodekey') ? $request->get('barcodekey') : str_pad($input['product_id'], 7, "0", STR_PAD_LEFT), $extension, public_path('img-barcode'));
         //if($request->has('fastinput'))return redirect()->back()->with('flash_message' ,  'Successfully saved barcode. <br/>File:<a href="'.$file.'">View</a>');
         if (file_exists(public_path('img-barcode') . '/' . $file)) {
             $input['imageurl'] = Url('img-barcode') . '/' . $file;
             $input['barcodekey'] = $request->get('barcodekey') ? str_pad($request->get('barcodekey'), 7, "0", STR_PAD_LEFT) : str_pad($input['product_id'], 7, "0", STR_PAD_LEFT);
             if ($barcode = $this->save($input)) {
                 $product->barcode_id = $barcode->id;
                 if ($product->save()) {
                     return redirect(route('barcode.show', $file))->with('flash_message', 'Successfully saved barcode. <br/>File:<a href="' . $file . '">View</a>');
                 }
             }
         }
     }
     return redirect()->back()->withErrors('Cannot save barcode. Try Again');
 }
示例#4
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $products = \bepc\Models\Product::all();
     $customers = $this->customer->all();
     return view('self.blade.order.create')->with(compact('products', 'customers'));
 }
示例#5
0
 public function processcomputation(Request $request)
 {
     $input = $request->all();
     $data = $input['data'];
     $products = [];
     $order = [];
     foreach ($data as $v) {
         $product = Product::find($v[0]);
         $recipe = $product->recipe;
         foreach ($recipe as $key => $value) {
             $ingredients = Ingredient::where('recipe_id', '=', $value['id'])->get();
             foreach ($ingredients as $ingredient) {
                 array_push($order, ['name' => $ingredient->name, 'quantity' => $ingredient->quantity * $v[1]]);
             }
         }
     }
     //$product = Product::find($input['data']);
     $recipe = $product->recipe;
     return $order;
 }