public function create()
 {
     //creation d'un objet du model Categories
     $model = new Categories();
     $categories = $model->getAllCategories();
     return view("Movies/create", ['categories' => $categories]);
 }
Esempio n. 2
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]);
 }
Esempio n. 3
0
 /**
  * Display restaurants having a particular category
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function viewAction($id)
 {
     $data = array();
     if (!$id) {
         $data['errors'][] = 'Invalid ID';
     } else {
         $data['id'] = $id;
     }
     $category = Categories::find($id);
     if (!$category) {
         $data['errors'][] = 'Category not found.';
         return view('cms.category.view', $data);
     }
     $restaurants_category = RestaurantsCategory::where('category_id', $id)->get();
     if ($restaurants_category) {
         $restaurants = array();
         foreach ($restaurants_category as $restaurant_category) {
             $restaurant = Restaurants::find($restaurant_category->restaurant_id);
             if (!$restaurant) {
                 $data['errors'][] = 'Cannot find restaurant ID ' . $restaurant->id . '.';
                 return view('cms.category.view', $data);
             }
             $restaurants[] = array('id' => $restaurant->id, 'name' => $restaurant->name, 'address' => $restaurant->address, 'telephone' => $restaurant->telephone, 'rating' => $restaurant->rating, 'budget' => $restaurant->budget);
             $restaurant = null;
         }
         $data['restaurants'] = $restaurants;
     }
     $data['page_title'] = ': ' . $category->name;
     return view('cms.category.view', $data);
 }
 /**
  * Page Read
  */
 public function edit($id)
 {
     $categories = Categories::all();
     $actors = Actors::all();
     $directors = Directors::all();
     $movie = Movies::find($id);
     return view('Movies/edit', ['movie' => $movie, 'categories' => $categories, 'actors' => $actors, 'directors' => $directors]);
 }
Esempio n. 5
0
 /**
  * Me retournera mes données de catégorie.
  */
 public function categories()
 {
     $tab = [];
     $categories = Categories::all();
     foreach ($categories as $categorie) {
         $tab[] = [$categorie->title, count($categorie->movies)];
     }
     return $tab;
 }
 public function store(CategoriesRequest $request, $id = null)
 {
     if ($id == null) {
         $categories = new Categories();
     } else {
         $categories = Categories::find($id);
     }
     $categories->title = $request->titre;
     $categories->description = $request->description;
     $categories->save();
     Session::flash('success', "La categorie : {$categories->title} a bien été ajouté !");
     return Redirect::route('categories_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
 }
 /**
  * action pour enregistrer en bdd les données du formulaire
  * la classe Request permet de receptionner les données en POST de manière sécurisée
  * @param $id (facultatif), valeur null par defaut
  */
 public function store(Request $request, $id = null)
 {
     if (!empty($id)) {
         $categorie = Categories::find($id);
     } else {
         $categorie = new Categories();
     }
     if (!empty($request->title)) {
         $categorie->title = $request->title;
     }
     $categorie->description = $request->description;
     /**
      * traitement de l'upload de l'image
      */
     $filename = "";
     // si j'ai un fichier image
     if ($request->hasFile('image')) {
         //recuperation de l'image
         $file = $request->file('image');
         //recuperation du nom du fichier
         $filename = $file->getClientOriginalName();
         //stockage du chemin vers lequel l'image va etre envoyée
         $destinationPath = public_path() . '/uploads/categories';
         //deplacement de l'image uploadée
         $file->move($destinationPath, $filename);
         //mise à jour de la propriété de l'objet Categories
         $categorie->image = asset('/uploads/categories/' . $filename);
     }
     if (!empty($categorie->title)) {
         // mise à jour de la propriété slug, reprise du title en minuscule, sans espace
         $categorie->slug = str_replace(" ", "-", strtolower($request->title));
     }
     //sauvegarde de l'objet Categories en base
     $categorie->save();
     //creer un messsage flash de type success
     if (!empty($id)) {
         Session::flash('success', "La catégorie {$categorie->title} a bien été modifiée.");
     } else {
         Session::flash('success', "La catégorie {$categorie->title} a bien été créée.");
     }
     //redirection vers la liste des catégories
     return Redirect::route('categories_index');
 }
 public function dashboard()
 {
     //compter les objets Actors
     $nbacteurs = Actors::count();
     //compter les objets Comments
     $nbcommentaires = Comments::count();
     //compter les objets Movies
     $nbfilms = Movies::count();
     //compter les objets Session
     $nbseances = Sessions::count();
     //compter les objets User
     $nbusers = User::count();
     //compter les objets Categories
     $nbcategories = Categories::count();
     //compter les objets Directors
     $nbdirectors = Directors::count();
     //compter les objets Medias
     $nbmedias = Medias::count();
     //moyenne d'age des Actors
     $actor = new Actors();
     $moyenne_acteurs = $actor->getAvgActors();
     //moyenne des Comments
     $comment = new Comments();
     $moyenne_commentaires = $comment->getAvgComments();
     //moyenne des Movies
     $movie = new Movies();
     $moyenne_presse = $movie->getAvgMovies();
     //moyenne des Sessions
     $session = new Sessions();
     $moyenne_seance = $session->getAvgSessions();
     //liste des 24 derniers Users
     $user = new User();
     $liste_users = $user->getLastUsers(24);
     //Pourcentage des films par distributeurs
     $movies_distributeur = $movie->getMoviesDistributeur();
     //liste des 15 prochaines Sessions
     $session = new Sessions();
     $liste_sessions = $session->getNextSessions(15);
     //pour utilisation de la 3ème méthode
     //qui retourne un timestamp
     $moyenne_acteurs = \Carbon\Carbon::createFromTimestamp($moyenne_acteurs);
     return view("Main/dashboard", ['nbacteurs' => $nbacteurs, 'moyenne_acteurs' => $moyenne_acteurs->diffInYears(), 'nbcommentaires' => $nbcommentaires, 'nbfilms' => $nbfilms, 'moyenne_commentaires' => round($moyenne_commentaires), 'moyenne_presse' => round($moyenne_presse), 'nbseances' => $nbseances, 'moyenne_seance' => round($moyenne_seance->moyenne), 'nbusers' => $nbusers, 'liste_users' => $liste_users, 'liste_sessions' => $liste_sessions, 'nbcategories' => $nbcategories, 'nbdirectors' => $nbdirectors, 'nbmedias' => $nbmedias, 'movies_distributeur' => $movies_distributeur]);
 }
Esempio n. 9
0
 public static function restaurantSearch($params)
 {
     $longitude = isset($params['long']) ? $params['long'] : 0;
     $latitude = isset($params['lat']) ? $params['lat'] : 0;
     $review_count_query = "(SELECT COUNT(id) FROM reviews WHERE reviews.restaurant_id = restaurants.id)";
     $checkin_count_query = "(SELECT COUNT(id) FROM check_ins WHERE check_ins.restaurant_id = restaurants.id)";
     $restaurants = Restaurants::select('restaurants.*', DB::raw("{$review_count_query} AS review_count"), DB::raw("{$checkin_count_query} AS checkin_count"));
     if (isset($params['name'])) {
         $restaurants->where('restaurants.name', 'LIKE', '%' . substr($params['name'], 0, 30) . '%');
     }
     if (isset($params['address'])) {
         $restaurants->where('restaurants.address', 'LIKE', '%' . substr($params['address'], 0, 30) . '%');
     }
     if (isset($params['tag']) && $params['tag'] != '') {
         $tag = $params['tag'];
         $restaurants->leftJoin('restaurants_category', 'restaurants.id', '=', 'restaurants_category.restaurant_id')->where('restaurants_category.category_id', $tag);
     }
     $search_results = $restaurants->paginate(CONSTANTS::RESTAURANTS_PARTIAL_SEARCH_PAGINATION_LIMIT);
     $distances = array();
     $data = array();
     foreach ($search_results as $count => $restaurant) {
         if ($restaurant['id'] == NULL) {
             continue;
         }
         if ($longitude > 0 && $latitude > 0) {
             $restaurant->distance = 3956 * 2 * asin(sqrt(pow(sin(($latitude - $restaurant->latitude) * pi() / 180 / 2), 2) + cos($latitude * pi() / 180) * cos($restaurant->latitude * pi() / 180) * pow(sin(($longitude - $restaurant->longitude) * pi() / 180 / 2), 2)));
         } else {
             $restaurant->distance = 0;
         }
         $data[$count]['restaurant'] = ModelFormatter::restaurantSearchFormat($restaurant);
         $distances[$count] = $restaurant->distance;
         $data[$count][KeyParser::categories] = Categories::getFormattedRestaurantCategories($restaurant->id);
     }
     array_multisort($distances, SORT_ASC, $data);
     $page = array(KeyParser::current => $search_results->currentPage(), KeyParser::number => $search_results->lastPage());
     return array(KeyParser::data => $data, KeyParser::page => $page);
 }
 /**
  * Page de liste des catégories
  */
 public function index()
 {
     // récupérer toutes mes catégories
     $categories = Categories::all();
     return view('Categories/index', ['categories' => $categories]);
 }
 /**
  * Page de liste des catégories.
  */
 public function index()
 {
     $categories = Categories::all();
     return view('Categories/index', ['categories' => $categories]);
 }
Esempio n. 12
0
            $category_cur = Categories::find($category_cur->parent);
            $categories[$category_cur->category_key] = $category_cur->name;
        } else {
            $categories[$category_cur->category_key] = $category_cur->name;
            break;
        }
    }
    $categories = array_reverse($categories);
    foreach ($categories as $key => $name) {
        $breadcrumbs->push($name, route('frontend.category', $key));
    }
});
// Detail
Breadcrumbs::register('detail', function ($breadcrumbs, $news_info) {
    $category_cur = Categories::find($news_info->category_id);
    $breadcrumbs->parent('home');
    $categories[$category_cur->category_key] = $category_cur->name;
    while (true) {
        if ($category_cur->parent != 0) {
            $category_cur = Categories::find($category_cur->parent);
            $categories[$category_cur->category_key] = $category_cur->name;
        } else {
            $categories[$category_cur->category_key] = $category_cur->name;
            break;
        }
    }
    $categories = array_reverse($categories);
    foreach ($categories as $key => $name) {
        $breadcrumbs->push($name, route('frontend.category', $key));
    }
});
Esempio n. 13
0
 public function getTagListAction()
 {
     $tags = Categories::getAllTags();
     $data[][KeyParser::category] = array(KeyParser::id => 0, KeyParser::type => CONSTANTS::CATEGORY_TAG, KeyParser::name => CONSTANTS::ALL_TAG_NAME, KeyParser::photo => CONSTANTS::ALL_TAG_PHOTO);
     foreach ($tags as $tag) {
         $data[][KeyParser::category] = ModelFormatter::categoryWithPhotoFormat($tag, CONSTANTS::CATEGORY_TAG);
     }
     $json_return[KeyParser::data] = $data;
     return response()->json($json_return);
 }
Esempio n. 14
0
 public function create()
 {
     $model_categories = new Categories();
     $categories = $model_categories->getAllCategories();
     return view('Movies/create', ['categories' => $categories]);
 }
Esempio n. 15
0
 /**
  * get all of the bookmarks of a user
  * /bookmarks/user/{user_id}
  *
  * @param $user_id
  * @return Response
  */
 public function userBookmarkListAction($user_id)
 {
     if (!is_numeric($user_id)) {
         return showErrorResponse('Incorrect User ID format');
     }
     $bookmark_list = Bookmarks::getBookmarkByUserId($user_id);
     $user_data = Users::find($user_id);
     $json_return[KeyParser::data] = array();
     if ($bookmark_list) {
         foreach ($bookmark_list as $bookmark) {
             $restaurant_data = Restaurants::find($bookmark->restaurant_id);
             if ($restaurant_data) {
                 $json_return[KeyParser::data][] = array(KeyParser::bookmark => ModelFormatter::bookmarkFormat($bookmark), KeyParser::user => ModelFormatter::userFormat($user_data), KeyParser::restaurant => ModelFormatter::restaurantBookmarkListViewFormat($restaurant_data), KeyParser::categories => Categories::getFormattedRestaurantCategories($bookmark->restaurant_id));
             }
         }
     }
     $json_return[KeyParser::page] = array(KeyParser::current => $bookmark_list->currentPage(), KeyParser::number => $bookmark_list->lastPage());
     return response()->json($json_return);
 }