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 run() { DB::table('products')->truncate(); $faker = Faker::create(); foreach (range(1, 40) as $i) { Product::create(['name' => $faker->word, 'description' => $faker->sentence(10), 'price' => $faker->randomFloat($nbMaxDecimals = 2, $min = 0, $max = 3000), 'featured' => $faker->boolean($chanceOfGettingTrue = 50), 'recommend' => $faker->boolean($chanceOfGettingTrue = 50), 'category_id' => $faker->numberBetween(1, 15)]); } }