public function contents($model_id = 0, $slug = '')
 {
     $network = $this->network;
     $theme = $network->theme;
     $theme = check_for_tour_theme($theme);
     Theme::setActive($theme);
     $data = $this->data;
     $model = Model::find($model_id);
     if ($model) {
         $contents = $model->contents()->published()->ofNetwork($this->network->id)->orderBy('id', 'desc')->get();
         $data['page_title'] = $model->name . ' Contents';
         $data['model'] = $model;
         $data['contents'] = $contents;
         $content_views = 0;
         foreach ($contents as $content) {
             $content_views = $content_views + $content->fake_views;
         }
         $data['content_views'] = $content_views;
         $username = \Request::server('PHP_AUTH_USER', 'sampleuser');
         $data['is_favorite'] = $username && Favorite::ofUsername($username)->hasFavorite('Model', $model->id)->count() ? 1 : 0;
         $this->breadcrumbs->addCrumb('Popular Models', url('models'));
         $this->breadcrumbs->addCrumb($model->name . ' Contents');
         return Theme::view('model.contents', $data);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $username = \Request::server('PHP_AUTH_USER', 'sampleuser');
     $response = [];
     $type = $request->input('type', '');
     $id = $request->input('id', '');
     $model = null;
     switch ($type) {
         case 'Content':
             $model = Content::find($request->input('id'));
             break;
         case 'Dvd':
             $model = Dvd::find($request->input('id'));
             break;
         case 'Dvdseries':
             $model = Dvdseries::find($request->input('id'));
             break;
         case 'Model':
             $model = Model::find($request->input('id'));
             break;
     }
     if ($username && $id && $model) {
         if (Favorite::ofUsername($username)->hasFavorite($type, $id)->count()) {
             $response['success'] = false;
             $response['message'] = 'Already in your favorites.';
         } else {
             $fav = new Favorite();
             $fav->username = $username;
             $model->favorites()->save($fav);
             $response['success'] = true;
             $response['message'] = 'Successfully added to your favorites.';
         }
     }
     return \Response::json($response);
 }