/** * Handle the event. * * @param StatusWasDeleted $event * @return void */ public function handle(StatusWasDeleted $event) { $status_comments = StatusComment::where('status_id', $event->status->id)->get(); foreach ($status_comments as $status_comment) { $status_comment->delete(); event(new StatusCommentWasDeleted($status_comment, Auth::user())); } }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $comment_id = $this->input('id'); $comment = StatusComment::findOrFail($comment_id); $user = Auth::user(); $is_owner = $comment->user_id == Auth::user()->id; if ($is_owner || $user->can('manage_comments')) { return true; } else { return false; } }
public function commentSave(UpdateStatusComment $request) { $data = $request->all(); $mention = new Mention(); $comment = StatusComment::findOrFail($data['id']); $comment->body_original = $data['body']; $comment->body = markdown($mention->parse($data['body'])); $comment->save(); flash()->success('Komentaras sėkmingai atnaujintas!'); return redirect()->route('status.show', $comment->status->id); }