示例#1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data = Companies::all();
     if ($data->count() == 0) {
         return redirect()->route('empresas.create');
     } else {
         return redirect()->route('empresas.edit', $data[0]->id);
     }
 }
示例#2
0
 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());
     //        });
 }