예제 #1
0
 public function generateCoach()
 {
     $faker = Factory::create();
     $coach = new Coach();
     $em = $this->getDoctrine()->getManager();
     for ($i = 0; $i < 10; $i++) {
         $coach->setFirstName($faker->firstNameMale);
         $coach->setLastName($faker->lastName);
         $coach->setBirthDay($faker->dateTime);
         $coach->setBiography($faker->text);
         $em->persist($coach);
     }
     $em->flush();
     $this->redirectToRoute('homepage');
 }
예제 #2
0
 /**
  * @Route("/admin/insert/coach/{id}", name="coach_insert_admin", requirements={"id" : "\d+"})
  *
  */
 public function generateCoachAction($id)
 {
     $teams = $this->getDoctrine()->getRepository('AppBundle:Team')->find($id);
     if (!$teams) {
         throw $this->createNotFoundException('Not found');
     }
     $faker = Factory::create();
     $em = $this->getDoctrine()->getManager();
     $coach = new Coach();
     $coach->setTeam($teams);
     $coach->setFirstName($faker->firstNameMale);
     $coach->setLastName($faker->lastName);
     $coach->setBirthDay($faker->dateTime);
     $coach->setBiography($faker->text);
     $em->persist($coach);
     $em->flush();
     $this->addFlash('notice', 'Add coach!');
     return $this->forward('AppBundle:Admin:show');
 }