public function index(Request $request) { $keyword = $request->input('keyword'); if ($keyword == '') { return redirect()->route('drama.index'); } $dramas = Drama::where('title', 'LIKE', '%' . $keyword . '%')->orWhere('alias', 'LIKE', '%' . $keyword . '%')->get(); $scs = Sc::where('name', 'LIKE', '%' . $keyword . '%')->orWhere('alias', 'LIKE', '%' . $keyword . '%')->get(); $clubs = Club::where('name', 'LIKE', '%' . $keyword . '%')->get(); return view('search.search', ['keyword' => $keyword, 'dramas' => $dramas, 'scs' => $scs, 'clubs' => $clubs]); }
public function show(Request $request, $id) { $club = Club::find($id, ['id', 'name', 'information', 'reviews']); $scs = Sc::select('id', 'name')->where('club_id', $id)->get(); $reviews = Screv::with(['user' => function ($query) { $query->select('id', 'name'); }])->select('id', 'user_id', 'title', 'content', 'created_at')->where('model_id', $id)->where('model', 1)->orderBy('id', 'desc')->take(20)->get(); if (Auth::check()) { $userReviews = Screv::select('id', 'title', 'content', 'created_at')->where('user_id', $request->user()->id)->where('model_id', $id)->where('model', 1)->get(); } else { $userReviews = 0; } return view('club.show', ['club' => $club, 'scs' => $scs, 'reviews' => $reviews, 'userReviews' => $userReviews]); }
public function edit(Request $request, $id) { $review = Screv::find($id); if ($review->user_id == $request->user()->id) { if ($review->model == 0) { $model = Sc::find($review->model_id, ['name']); } else { $model = Club::find($review->model_id, ['name']); } return view('screv.edit', ['review' => $review, 'model' => $model]); } else { return redirect()->back(); } }
public function update(Request $request, $id) { $this->validate($request, ['sc' => 'required', 'job' => 'required']); $role = Role::find($id); if ($sc = Sc::select('id')->where('name', $request->input('sc'))->first()) { $role->sc_id = $sc->id; } else { return redirect()->back()->withInput()->withErrors('未找到该SC'); } $role->job = $request->input('job'); $role->note = $request->input('note'); $role->user_id = $request->user()->id; if ($role->save()) { return redirect()->route('episode.sc', [$role->episode_id]); } else { return redirect()->back()->withInput()->withErrors('修改失败'); } }
public function versions($id) { $sc = Sc::find($id, ['id', 'name']); $versions = Scver::with(['user' => function ($query) { $query->select('id', 'name'); }, 'club' => function ($query) { $query->select('id', 'name'); }])->select('user_id', 'first', 'name', 'alias', 'club_id', 'jobs', 'information', 'created_at', 'updated_at')->where('sc_id', $id)->orderBy('updated_at', 'desc')->get(); return view('sc.versions', ['sc' => $sc, 'versions' => $versions]); }