Inheritance: extends Illuminate\Database\Eloquent\Model
コード例 #1
0
ファイル: IndexController.php プロジェクト: suowei/saoju
 public function episodes()
 {
     $episodes = Episode::join('dramas', function ($join) {
         $join->on('episodes.drama_id', '=', 'dramas.id');
     })->select('dramas.title as dramaTitle', 'dramas.type as type', 'dramas.original as original', 'episodes.id as episodeId', 'episodes.title as episodeTitle', 'episodes.release_date as releaseDate', 'dramas.sc as sc', 'episodes.alias as alias', 'episodes.poster_url as posterUrl', 'dramas.era as era', 'dramas.genre as genre', 'dramas.state as state', 'episodes.duration as duration')->orderByRaw('release_date desc, episodes.id desc')->simplePaginate(20);
     return $episodes;
 }
コード例 #2
0
ファイル: AppServiceProvider.php プロジェクト: suowei/saoju
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Episode::created(function ($episode) {
         DB::table('users')->whereIn('id', function ($query) use($episode) {
             $query->select('user_id')->from('favorites')->where('drama_id', $episode->drama_id)->whereIn('type', [0, 1]);
         })->increment('dramafeed', 1);
     });
 }
コード例 #3
0
ファイル: ReviewController.php プロジェクト: suowei/saoju
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     if ($request->has('episode')) {
         return view('review.create')->withDrama(Drama::find($request->input('drama'), ['id', 'title']))->withEpisode(Episode::find($request->input('episode'), ['id', 'title']));
     } else {
         return view('review.create')->withDrama(Drama::find($request->input('drama'), ['id', 'title']));
     }
 }
コード例 #4
0
ファイル: EpfavController.php プロジェクト: suowei/saoju
 public function edit(Request $request, $episode_id)
 {
     $episode = Episode::find($episode_id, ['id', 'drama_id', 'title']);
     $drama = Drama::find($episode->drama_id, ['title']);
     $user_id = $request->user()->id;
     $favorite = Epfav::select('type', 'rating')->where('user_id', $user_id)->where('episode_id', $episode_id)->first();
     $review = Review::select('title', 'content', 'visible')->where('user_id', $user_id)->where('episode_id', $episode_id)->first();
     return view('epfav.edit', ['episode' => $episode, 'drama' => $drama, 'favorite' => $favorite, 'review' => $review]);
 }
コード例 #5
0
 public function store($episodeId, Request $request)
 {
     if (!Auth::user()->isAdmin()) {
         abort(403);
     }
     $episode = Episode::findOrFail($episodeId);
     $topic = Topic::findOrFail($request->get('topic_id'));
     $episode->topics()->save($topic);
 }
コード例 #6
0
ファイル: EdController.php プロジェクト: suowei/saoju
 public function create(Request $request)
 {
     $drama = Drama::find($request->input('drama'), ['id', 'title']);
     if ($request->has('episode')) {
         $episode = Episode::find($request->input('episode'), ['id', 'title']);
     } else {
         $episode = null;
     }
     return view('ed.create', ['drama' => $drama, 'episode' => $episode]);
 }
コード例 #7
0
ファイル: RoleController.php プロジェクト: suowei/saoju
 public function edit(Request $request, $id)
 {
     $role = Role::find($id, ['id', 'drama_id', 'episode_id', 'sc_id', 'job', 'note', 'user_id']);
     if ($role->user_id != $request->user()->id) {
         return '抱歉, 目前仅支持添加此条目的用户编辑关联信息> <';
     }
     $drama = Drama::find($role->drama_id, ['title']);
     $episode = Episode::find($role->episode_id, ['title']);
     $sc = Sc::find($role->sc_id, ['name']);
     return view('role.edit', ['role' => $role, 'drama' => $drama, 'episode' => $episode, 'sc' => $sc]);
 }
コード例 #8
0
ファイル: EpisodeController.php プロジェクト: suowei/saoju
 public function show(Request $request, $id)
 {
     $episode = Episode::find($id, ['id', 'drama_id', 'title', 'alias', 'release_date', 'url', 'sc', 'duration', 'poster_url', 'introduction', 'reviews']);
     $episode->load(['drama' => function ($query) {
         $query->select('id', 'title', 'type', 'era', 'genre', 'original');
     }]);
     if (Auth::check()) {
         $episode->userFavorite = Epfav::select('type', 'rating')->where('user_id', $request->user()->id)->where('episode_id', $id)->first();
     }
     return $episode;
 }
コード例 #9
0
ファイル: IndexController.php プロジェクト: suowei/saoju
 public function index(Request $request)
 {
     //判断url中是否有性向参数,若没有就默认性向为耽美type=0
     if ($request->has('type')) {
         $type = $request->input('type');
     } else {
         $type = 0;
     }
     //若type为-1,则查询全部新剧,否则按性向即type值查询
     if ($type < 0) {
         $episodes = Episode::join('dramas', function ($join) {
             $join->on('episodes.drama_id', '=', 'dramas.id')->where('episodes.release_date', '>=', date("Y-m-d", strtotime("-7 day")));
         })->select('dramas.title as drama_title', 'dramas.type as type', 'dramas.original as original', 'episodes.id as episode_id', 'episodes.title as episode_title', 'episodes.reviews as reviews', 'episodes.release_date as release_date', 'dramas.sc as sc', 'episodes.alias as alias', 'episodes.poster_url as poster_url', 'dramas.era as era', 'dramas.genre as genre', 'dramas.state as state', 'episodes.duration as duration')->orderBy('episode_id', 'desc')->get();
     } else {
         $episodes = Episode::join('dramas', function ($join) use($type) {
             $join->on('episodes.drama_id', '=', 'dramas.id')->where('dramas.type', '=', $type)->where('episodes.release_date', '>=', date("Y-m-d", strtotime("-7 day")));
         })->select('dramas.title as drama_title', 'dramas.type as type', 'dramas.original as original', 'episodes.id as episode_id', 'episodes.title as episode_title', 'episodes.reviews as reviews', 'episodes.release_date as release_date', 'dramas.sc as sc', 'episodes.alias as alias', 'episodes.poster_url as poster_url', 'dramas.era as era', 'dramas.genre as genre', 'dramas.state as state', 'episodes.duration as duration')->orderBy('episode_id', 'desc')->get();
     }
     $top10 = $episodes->take(10);
     //将一周新剧按发剧日期分组
     $episodes = $episodes->groupBy('release_date');
     //查询60天收藏数前10的剧单
     $lists = Listfav::with(['dramalist' => function ($query) {
         $query->select('id', 'title');
     }])->select(DB::raw('count(*) as favorite_count, list_id'))->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-60 day")))->groupBy('list_id')->orderBy('favorite_count', 'desc')->take(10)->get();
     //最新剧单
     $newlists = Dramalist::select('id', 'title')->orderBy('id', 'desc')->take(10)->get();
     //查询30天评论数前10的剧集id
     $hotDramas = Review::with(['drama' => function ($query) {
         $query->select('id', 'title');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as review_count, drama_id'))->groupBy('drama_id')->orderBy('review_count', 'desc')->take(10)->get();
     //查询30天收藏前10的剧集id
     $hotFavorites = Favorite::with(['drama' => function ($query) {
         $query->select('id', 'title');
     }])->where('created_at', '>=', date("Y-m-d H:i:s", strtotime("-30 day")))->select(DB::raw('count(*) as favorite_count, drama_id'))->groupBy('drama_id')->orderBy('favorite_count', 'desc')->take(10)->get();
     //查询最新10条新剧的添加历史
     $versions = Dramaver::select('user_id', 'drama_id', 'created_at')->where('first', 1)->orderBy('drama_id', 'desc')->take(10)->get();
     $versions->load(['user' => function ($query) {
         $query->select('id', 'name');
     }]);
     $versions->load(['drama' => function ($query) {
         $query->select('id', 'title', 'sc');
     }]);
     $versions = $versions->filter(function ($version) {
         return isset($version->drama->id);
     });
     return view('index', ['type' => $type, 'episodes' => $episodes, 'top10' => $top10, 'lists' => $lists, 'newlists' => $newlists, 'hotDramas' => $hotDramas, 'hotFavorites' => $hotFavorites, 'versions' => $versions]);
 }
コード例 #10
0
ファイル: ItemController.php プロジェクト: suowei/saoju
 public function create(Request $request)
 {
     $lists = Dramalist::select('id', 'title')->where('user_id', $request->user()->id)->get();
     if ($request->has('drama')) {
         $drama = Drama::find($request->input('drama'), ['id', 'title']);
         return view('item.create', ['drama' => $drama, 'lists' => $lists]);
     } else {
         if ($request->has('episode')) {
             $episode = Episode::find($request->input('episode'), ['id', 'drama_id', 'title']);
             $drama = Drama::find($episode->drama_id, ['id', 'title']);
             return view('item.create', ['drama' => $drama, 'episode' => $episode, 'lists' => $lists]);
         } else {
             return redirect()->back();
         }
     }
 }
コード例 #11
0
ファイル: EpisodeController.php プロジェクト: suowei/saoju
 public function songs($id)
 {
     $episode = Episode::find($id, ['id', 'drama_id', 'title']);
     $drama = Drama::find($episode->drama_id, ['title']);
     $eds = Ed::with(['song' => function ($query) {
         $query->select('id', 'title');
     }])->where('episode_id', $id)->get();
     return view('episode.songs', ['drama' => $drama, 'episode' => $episode, 'eds' => $eds]);
 }
コード例 #12
0
ファイル: DramaController.php プロジェクト: suowei/saoju
 public function sc($id)
 {
     $drama = Drama::find($id, ['id', 'title']);
     $episodes = Episode::select('id', 'title')->where('drama_id', $id)->orderByRaw('release_date, id')->get();
     $roles = Role::with(['sc' => function ($query) {
         $query->select('id', 'name');
     }])->select('id', 'episode_id', 'sc_id', 'job', 'note')->where('drama_id', $id)->orderBy('job')->get();
     $roles = $roles->groupBy('episode_id');
     return view('drama.sc', ['drama' => $drama, 'episodes' => $episodes, 'roles' => $roles]);
 }
コード例 #13
0
ファイル: RefreshData.php プロジェクト: linosteenkamp/pompong
 private function getEpisodes($maxSeason, $tvdbid)
 {
     $client = new Client(['base_uri' => 'http://' . getenv('POMPONG_SIKBEARD_ADDRESS') . '/api/' . getenv('POMPONG_SICKBEARD_APIKEY') . '/']);
     for ($i = 1; $i <= $maxSeason; $i++) {
         $response = $client->request('GET', '?cmd=show.seasons&tvdbid=' . $tvdbid . '&season=' . $i);
         $seasonData = json_decode($response->getBody(), true);
         foreach ($seasonData['data'] as $key => $value) {
             $response = $client->request('GET', '?cmd=episode&tvdbid=' . $tvdbid . '&season=' . $i . '&episode=' . $key . '&full_path=1');
             $episodeData = json_decode($response->getBody(), true);
             $episode = Episode::firstOrNew(['show_id' => $tvdbid, 'season' => $i, 'episode_no' => $key]);
             $episode->show_id = $tvdbid;
             $episode->season = $i;
             $episode->episode_no = $key;
             $episode->name = $episodeData['data']['name'];
             $episode->status = $episodeData['data']['status'];
             $episode->airdate = $episodeData['data']['airdate'];
             $episode->description = $episodeData['data']['description'];
             $episode->file_size = $episodeData['data']['file_size'];
             $episode->location = $episodeData['data']['location'];
             $episode->save();
         }
     }
 }
コード例 #14
0
 public function show($id)
 {
     return new ApiEpisode(Episode::findOrFail($id));
 }
コード例 #15
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $lessons = Lesson::all();
     $episodes = Episode::all();
     return view('episodes.index', compact('lessons', 'episodes'));
 }
コード例 #16
0
 public function destroy($id)
 {
     $episode = Episode::findOrFail($id);
     $episode->delete();
     return response()->json(['success' => true, 'message' => 'Successfully deleted episode.']);
 }
コード例 #17
0
ファイル: UserController.php プロジェクト: suowei/saoju
 public function episode2015(Request $request)
 {
     $user_id = $request->user()->id;
     $episodes = Episode::with(['drama' => function ($query) {
         $query->select('id', 'title', 'type', 'era', 'original', 'state', 'sc');
     }])->join('epfavs', function ($join) use($user_id) {
         $join->on('episodes.id', '=', 'epfavs.episode_id')->where('epfavs.user_id', '=', $user_id)->where('release_date', '>=', '2015-01-01')->where('release_date', '<=', '2015-12-31');
     })->select('id', 'drama_id', 'title', 'release_date', 'rating')->orderByRaw('rating desc, release_date')->paginate(50);
     return view('user.episode2015', ['episodes' => $episodes]);
 }