public function index() { for ($i = 0; $i < 20; $i++) { Factory::create(App\Companies::class, 1); $company = Companies::all()->last(); $randNum = rand(0, 10); for ($x = 0; $x < $randNum; $x++) { Factory::create(App\Employees::class); $user = Employees::all()->last(); $company->employees->attach($user); } } // factory(App\Companies::class, 50)->create()->each(function($c) { // $c->employees()->addTo(factory(App\Employees::class)->make()); // }); }
public function index() { $employees = Employees::all(); //return $aData; return view('pages.home', compact('employees')); }