/** * Run the database seeds. * * @return void */ public function run() { DB::table('subindustries')->truncate(); $faker = Faker::create(); foreach (range(1, 20) as $index) { Subindustry::create(['name' => 'Subindustry ' . $index, 'industry_id' => Industry::find($faker->numberBetween(1, 20))->id]); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('products')->truncate(); $faker = Faker::create(); foreach (range(1, 20) as $index) { Product::create(['name' => 'Product ' . $index, 'subindustry_id' => Subindustry::all()->get($faker->numberBetween(1, 20))->id]); } }
/** * Show the form for editing the specified Product. * * @param int $id * * @return Response */ public function edit($id) { $product = $this->productRepository->findWithoutFail($id); $subindustries = Subindustry::lists('name', 'id'); if (empty($product)) { Flash::error('Product not found'); return redirect(route('products.index')); } return view('products.edit')->with('product', $product)->with('subindustries', $subindustries); }