Ejemplo n.º 1
0
 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]];
 }