コード例 #1
0
 /**
  * Bind data to the view.
  *
  * @param View $view
  */
 public function compose(View $view)
 {
     $products = Product::allLists();
     $shopkeepers = User::searchShopkeepers();
     $communes = ['1' => 'Comuna 1', '2' => 'Comuna 2', '3' => 'Comuna 3', '4' => 'Comuna 4', '5' => 'Comuna 5', '6' => 'Comuna 6', '7' => 'Comuna 7', '8' => 'Comuna 8'];
     $view->with(['communes' => $communes, 'products' => $products, 'shopkeepers' => $shopkeepers]);
 }
コード例 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function postIndex(Request $request)
 {
     $id = Auth::user()->id;
     if ($request->has('user-id')) {
         $id = $request->get('user-id');
     }
     $product = Product::findOrFail($request->get('product'));
     $production = Production::firstOrNew(['user_id' => $id, 'product_id' => $product->id]);
     if (!$production->exists) {
         $production->months = $request->get('months');
         $production->save();
         $production->load('product');
         $msg = 'Producto ' . $product->name . ' agreagdo';
         return response()->json(['msg' => $msg, 'production' => $production]);
     }
     return response()->json(['errors' => ['El producto ya fue agregado']]);
 }
コード例 #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function postIndex(Request $request, $id = null)
 {
     $id = Auth::user()->id;
     if ($request->has('user-id')) {
         $id = $request->get('user-id');
     }
     $product = Product::findOrFail($request->get('product'));
     $shoppingInterest = ShoppingInterest::firstOrNew(['user_id' => $id, 'product_id' => $product->id]);
     if (!$shoppingInterest->exists) {
         $shoppingInterest->amount = $request->get('amount');
         $shoppingInterest->unit = $request->get('unit');
         $shoppingInterest->save();
         $msg = 'Producto ' . $product->name . ' agreagdo';
         return response()->json(['msg' => $msg, 'product' => $product, 'shoppingInterest' => $shoppingInterest]);
     }
     return response()->json(['errors' => ['El producto ya fue agregado']]);
 }
コード例 #4
0
 /**
  * Display a listing of the Products.
  *
  * @return \Illuminate\Http\Response
  */
 public function getProductionProducts(Request $request)
 {
     // $products = $this->getFormatSelect2(Auth::user()->productionProductsLists());
     $products = $this->getFormatSelect2(Product::getAllWithProductionLists());
     return response()->json($products);
 }
コード例 #5
0
ファイル: User.php プロジェクト: NuestraMarca/tenderos
 public function productionProductsLists()
 {
     return Product::allLists(null, [], $this->productionProducts->lists('id')->all());
 }