public function update(Request $request, $id) { $param = $request->all(); $review = Review::find($id); $review->update($param); $requirement = $review->requirement; if ($review->status == 'pass') { $requirement->status = 'passed'; } elseif ($review->status == 'unpass') { $requirement->status = 'opening'; } $requirement->save(); return $review; }
public function deleteReview(Request $request) { $this->validate($request, ['review_id' => 'required|integer', 'created_at' => 'required|date', 'reason' => 'required|max:255']); $review = Review::find($request->input('review_id')); if ($review->created_at == $request->input('created_at')) { $review->banned = $request->input('reason'); if ($review->save()) { return redirect('/'); } else { return redirect()->back()->withInput()->withErrors('屏蔽失败'); } } return redirect()->back()->withInput()->withErrors('校验失败,请仔细核对评论ID与评论时间'); }
public function destroy(Request $request, $id) { $review = Review::find($id); if ($review->user_id == $request->user()->id) { if ($review->delete()) { DB::table('users')->where('id', $review->user_id)->decrement('reviews'); DB::table('dramas')->where('id', $review->drama_id)->decrement('reviews'); if ($review->episode_id) { DB::table('episodes')->where('id', $review->episode_id)->decrement('reviews'); } return ['result' => 'success']; } } return response('非评论用户', 422); }
public function activate(Request $request, $id, $param) { $data[$param] = $request->checked; Review::find($id)->update($data); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $review = Review::find($id); if (Auth::check()) { if ($review->fr_usr_id == Auth::user()->id) { return view('reviews.edit', compact('review')); } else { return redirect(Config::get('url.home')); } } else { return redirect(Config::get('url.home')); } return redirect(Ccnfig::get('url.home')); }
/** * Get all of the review by ID. * * @param int $appRoleId * * @return Collection */ public function byId($reviewId) { return Review::find($reviewId); }
/** * delete review * * @param Request $request * @return Response */ public function deleteReview($id) { $review = Review::find($id); if ($review) { if ($review->reviewer_id == Auth::user()->id) { $review->delete(); return redirect(URL::previous() . '#reviews')->with('success', 'Review deleted!'); } } return redirect(URL::previous())->with('error', 'Error in deleting review!!'); }
/** * */ public function getDoDelete($review_id) { $review = \App\Review::find($review_id); if (is_null($review)) { \Session::flash('flash_message', 'Review not found.'); return redirect('\\landmarks'); } $review->delete(); \Session::flash('flash_message', 'Review #' . $review->id . ' was deleted.'); return redirect('/reviews'); }
public function editReview($idReview = 0, $idStaff = 0) { $staff = Staff::find($idStaff); $review = Review::find($idReview); if (Gate::allows('check-leader')) { if ($staff->level->role->name == 'Manager' || $staff->department_id != Auth::user()->department_id || $staff->id == Auth::user()->id || $review->reviewer_id != Auth::user()->id) { return redirect()->route('admin.staff.index')->with('message', 'Access is denied'); } } // is Manager if (Gate::allows('check-manager')) { if ($staff->level->role->name == 'Manager') { return redirect()->route('admin.staff.index')->with('message', 'Access is denied'); } } // is Developer // if is manager / != department / yourself // denied if (Gate::allows('check-developer')) { if ($staff->level->role->name == 'Manager' || $staff->department_id != Auth::user()->department_id || $staff->id == Auth::user()->id || $review->reviewer_id != Auth::user()->id) { return redirect()->route('admin.department.index')->with('message', 'Access is denied'); } } return view('admin.review.update', compact('staff', 'review')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $review = Review::find($id); if ($review->user_id == Auth::id()) { if ($review->delete()) { DB::table('users')->where('id', $review->user_id)->decrement('reviews'); DB::table('dramas')->where('id', $review->drama_id)->decrement('reviews'); if ($review->episode_id) { DB::table('episodes')->where('id', $review->episode_id)->decrement('reviews'); } } } return redirect()->back(); }