Пример #1
0
 public function dashboard()
 {
     // METHODE ORM
     $nbacteurs = Actors::count();
     $nbcommentaire = Commentaire::count();
     $avgcommentaire = Commentaire::avg('note');
     $countnotepresse = Movies::count('note_presse');
     $avgnotepresse = Movies::avg('note_presse');
     $moviescount = Movies::count('id');
     $avgmovies = Movies::avg('duree');
     $actor = new Actors();
     //methode query builder
     $avgacteur = $actor->getAvgActors();
     $notepresse2 = new Movies();
     $countnotepresse2 = $notepresse2->getAvgNoteMovies();
     $avgsession = Sessions::count('id');
     $session = new Sessions();
     $sessionavg = $session->getAvgSession2();
     $lastuser = new User();
     $last = $lastuser->getLastUsers();
     // 15 prochaine (TROISIEME METHODE )
     $nextsession = Sessions::where('date_session', "<", Carbon::now())->take(15)->get();
     // premiere methode avec 2 jointures :
     $seance = new Sessions();
     $resultseance = $seance->getNextSession();
     $allcategories = Categories::all();
     $alldirectors = Directors::count('id');
     $distrib = new Movies();
     $distributeur = $distrib->countDistributeur();
     $villeacteur = new Actors();
     $villebyacteur = $villeacteur->getVilleByActors();
     // exit(dump($villebyacteur ));
     return view('Main/dashboard', ['nbacteurs' => $nbacteurs, 'nbcommentaire' => $nbcommentaire, 'avgacteur' => $avgacteur->age, 'avgcommentaire' => $avgcommentaire, 'avgnotepresse' => $avgnotepresse, 'countnotepresse' => $countnotepresse, 'moviescount' => $moviescount, 'avgmovies' => $avgmovies, 'countnotepresse2' => $countnotepresse2->note, 'avgsession' => $avgsession, 'sessionavg' => $sessionavg->date, 'last' => $last, 'nextsession' => $nextsession, 'allcategories' => $allcategories, 'alldirectors' => $alldirectors, 'distributeur' => $distributeur, 'villeacteur' => $villebyacteur]);
 }
Пример #2
0
 public function like($id, $action)
 {
     $commentaire = Commentaire::find($id);
     $likes = session('favoris', []);
     if ($action == "favoris") {
         $likes[$id] = $commentaire->id;
     } else {
         unset($likes[$id]);
     }
     Session::put("favoris", $likes);
     Session::flash('success', "Le commentaire numero ' {$commentaire->id}'  a été like");
     return Redirect::route('commentaires_index');
 }