Exemple #1
0
 public function post(DirectorsRequest $request)
 {
     $director = new directorsdb();
     $director->firstname = $request->firstname;
     $director->lastname = $request->lastname;
     $director->dob = $request->dob;
     $director->biography = $request->biography;
     $filename = "";
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $filename = $file->getClientOriginalName();
         $destinationPath = public_path() . '/uploads/director/';
         $file->move($destinationPath, $filename);
     }
     $director->image = asset('uploads/director/' . $filename);
     $director->save();
     Session::flash('success', "L'acteur {$director->firstname} {$director->lastname} est injecté dans la BDD.");
     return Redirect::route('directors.index');
 }
 public function store(DirectorsRequest $request)
 {
     $directors = new Directors();
     $directors->firstname = $request->nom;
     $directors->lastname = $request->prenom;
     $directors->dob = $request->dob;
     $filename = "";
     if ($request->hasFile('image')) {
         //je recupere mon fichier :
         $file = $request->file('image');
         //je recupere le nom du fichier :
         $filename = $file->getClientOriginalName();
         //je stock le chemin veers lequel mon image va etre envoyé
         $destinationPath = public_path() . '/uploads/directors';
         //je deplace mon fichier uploader :
         $file->move($destinationPath, $filename);
     }
     $directors->save();
     Session::flash('success', "Le réalisateur {$directors->firstname} a été ajouté");
     return Redirect::route('directors_index');
     //recupere le film de mon film ac la methode POST
     //input (name de mon champ) permet de recuperer la donéne titre de maniere safely
 }