public function adminChange(User $user, Problem $problem) { if ($problem->active == 0) { //the post is already disabled $problem->update(['active' => 1]); Flash::success(trans('admin/messages.problemActivate')); } elseif ($problem->active == 1) { //the post is already enabled $problem->update(['active' => 0]); Flash::success(trans('admin/messages.problemBan')); } return redirect()->back(); }
public function problem(Request $request, Problem $problem) { $group = $problem->parentable; if ($request->user()->can('join-group', [$group])) { return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 1, 'msg' => 'تنها اعضای گروه می توانند پاسخ خود را برای این پرسش بیان نمایند.', 'msgType' => 'danger', 'returns' => ['num_comments' => '']]; } $user = Auth::user(); $comment = $problem->comments()->create(['user_id' => $user->id, 'body' => $request->input('body'), 'num_like' => 0, 'num_dislike' => 0]); $num_comments = $problem->comments()->count(); $problem->update(['num_comment' => $num_comments]); $this->groupStream($comment); return ['hasCallback' => 1, 'callback' => 'post_comment', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['new_comment' => view('partials.problemComment', compact('user', 'comment', 'problem'))->render(), 'num_comments' => $num_comments]]; }