コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 public function dvdSeries($id)
 {
     if (Input::has('o')) {
         $order = Input::get('o');
         switch ($order) {
             case 'v':
                 $orderBy = "views";
                 $sortName = "Most Viewed";
                 break;
             case 'r':
                 $orderBy = "rating";
                 $sortName = "Top Rated";
                 break;
             case 'f':
                 $orderBy = "favorites";
                 $sortName = "Most Popular";
                 break;
             default:
                 $orderBy = "publish_date";
                 $sortName = "Newest";
                 break;
         }
     } else {
         $order = "";
         $orderBy = "publish_date";
         $sortName = "Newest";
     }
     $network = $this->network;
     $theme = $network->theme;
     Theme::setActive($theme);
     $data = $this->data;
     $series = Dvdseries::find($id);
     $data['series'] = $series;
     $data['dvds'] = $series->dvds()->get();
     $data['page_title'] = $series->title;
     $username = \Request::server('PHP_AUTH_USER', 'sampleuser');
     $data['is_favorite'] = $username && Favorite::ofUsername($username)->hasFavorite('Dvdseries', $series->id)->count() ? 1 : 0;
     $data['tags'] = Tag::ofNetwork($this->network->id)->ofDvds()->get();
     $data['sortname'] = $sortName;
     $this->breadcrumbs->addCrumb('DVD');
     return Theme::view('dvd.series', $data);
 }