/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { $nb_rep = $request->input('nb_rep'); for ($i = 0; $i < $nb_rep; $i++) { $horaire = new Horaire(); $horaire->h_debut = $request->input('h_debut'); $horaire->h_fin = $request->input('h_fin'); $horaire->date = date_create($request->input('date_debut')); $horaire->matiere_id = $request->input('matiere_id'); $nb_days = $i * 7; date_add($horaire->date, date_interval_create_from_date_string($nb_days . ' days')); $horaire->save(); } return Redirect('/app/cours'); }