コード例 #1
0
 public function save(Request $request)
 {
     $suppliers = $request->get('supplier_id');
     $product = Product::create($request->all());
     foreach ($suppliers as $supp) {
         SupplierProducts::create(['product_id' => $product->id, 'supplier_id' => $supp]);
     }
     $products = Product::all();
     return view('pages.products', ['products' => $products]);
 }
コード例 #2
0
 public function save(Request $request)
 {
     //    	$product = Product::create($request->all());
     //        return $product;
     $suppliers = $request->get('supplier_id');
     $product = Product::create($request->all());
     foreach ($suppliers as $supp) {
         \App\Models\SupplierProducts::create(['product_id' => $product->id, 'supplier_id' => $supp]);
     }
 }