public function run() { DB::table('products')->truncate(); $faker = Factory::create(); $categories = categorie::all()->lists('id'); foreach (range(1, 50) as $index) { product::create(['name' => $faker->sentence(4), 'categorie_id' => $faker->randomElement($categories), 'description' => $faker->text, 'price' => $faker->randomFloat(2, 2, 200), 'slug' => $faker->slug]); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $categories = categorie::all(); return view('cms.categories.categories', compact('categories')); }
public function create() { $product = new product(); $categories = categorie::all(); return view('cms.products.create', compact('product', 'categories')); }