/** * 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'])); } }
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]); }
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]); }
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]); }
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(); } } }
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]); }
public function edit(Request $request, $drama_id) { $drama = Drama::find($drama_id, ['id', 'title']); $user_id = $request->user()->id; $favorite = Favorite::select('type', 'rating', 'tags')->where('user_id', $user_id)->where('drama_id', $drama_id)->first(); $review = Review::select('title', 'content', 'visible')->where('user_id', $user_id)->where('drama_id', $drama_id)->where('episode_id', 0)->first(); $tagmaps = Tagmap::with('tag')->select(DB::raw('count(*) as count, tag_id'))->where('user_id', $request->user()->id)->groupBy('tag_id')->orderBy('count', 'desc')->take(15)->get(); return view('favorite.edit', ['drama' => $drama, 'favorite' => $favorite, 'review' => $review, 'tagmaps' => $tagmaps]); }
public function show(Request $request, $id) { $drama = Drama::find($id, ['id', 'title', 'alias', 'type', 'era', 'genre', 'original', 'count', 'state', 'sc', 'introduction', 'reviews']); $drama->load(['episodes' => function ($query) { $query->select('id', 'drama_id', 'title', 'alias', 'release_date', 'poster_url')->orderByRaw('release_date, id')->get(); }]); $drama->commtags = Tagmap::with('tag')->select(DB::raw('count(*) as count, tag_id'))->where('drama_id', $id)->groupBy('tag_id')->orderBy('count', 'desc')->take(5)->get(); if (Auth::check()) { $user_id = $request->user()->id; $drama->userFavorite = Favorite::select('id', 'type', 'rating', 'tags')->where('user_id', $user_id)->where('drama_id', $id)->first(); $drama->userTags = Tagmap::with('tag')->select(DB::raw('count(*) as count, tag_id'))->where('user_id', $user_id)->groupBy('tag_id')->orderBy('count', 'desc')->take(10)->get(); } return $drama; }