예제 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $network = $this->network;
     $theme = $network->theme;
     $theme = check_for_tour_theme($theme);
     Theme::setActive($theme);
     $data = $this->data;
     $data['page_title'] = 'My Favorites';
     $username = \Request::server('PHP_AUTH_USER', 'sampleuser');
     $fav_content_ids = Favorite::ofUsername($username)->favorableType('Content')->lists('favorable_id');
     $fav_contents = Content::whereIn('id', $fav_content_ids)->get();
     $fav_dvd_ids = Favorite::ofUsername($username)->favorableType('Dvd')->lists('favorable_id');
     $fav_dvds = Dvd::whereIn('id', $fav_dvd_ids)->get();
     $fav_dvdseries_ids = Favorite::ofUsername($username)->favorableType('Dvdseries')->lists('favorable_id');
     $fav_dvdseries = Dvdseries::whereIn('id', $fav_dvdseries_ids)->get();
     $fav_models_ids = Favorite::ofUsername($username)->favorableType('Model')->lists('favorable_id');
     $fav_models = Model::whereIn('id', $fav_models_ids)->get();
     $favs = collect();
     $favs = $favs->merge($fav_contents)->merge($fav_dvds)->merge($fav_models)->merge($fav_dvdseries);
     $data['favorites'] = $favs->all();
     $this->breadcrumbs->addCrumb('My Favorites');
     return Theme::view('favorite.index', $data);
 }