public function run() { DB::table('products')->truncate(); $faker = Faker::create(); foreach (range(1, 40) as $i) { Product::create(['name' => $faker->word(), 'description' => $faker->sentence(), 'price' => $faker->randomNumber(2), 'category_id' => $faker->numberBetween(1, 10)]); } }
public function add($id) { $cart = $this->getCart(); $product = Product::find($id); $cart->add($id, $product->name, $product->price); Session::set('cart', $cart); return redirect()->route('cart'); }
public function product($id) { $product = Product::find($id); $categories = Category::all(); return view('store.product', compact('categories', 'product')); }