PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` middleware('web'); if (Config::get('comments.guest_commenting') == true) { $this->middleware('auth')->except('store'); $this->middleware(ProtectAgainstSpam::class)->only('store'); } else { $this->middleware('auth'); } } /** * Creates a new comment for given model. */ public function store(Request $request) { // If guest commenting is turned off, authorize this action. if (Config::get('comments.guest_commenting') == false) { Gate::authorize('create-comment', Comment::class); } // Define guest rules if user is not logged in. if (!Auth::check()) { $guest_rules = [ 'guest_name' => 'required|string|max:255', 'guest_email' => 'required|string|email|max:255', ]; } // Merge guest rules, if any, with normal validation rules. Validator::make($request->all(), array_merge($guest_rules ?? [], [ 'commentable_type' => 'required|string', 'commentable_id' => 'required|string|min:1', 'message' => 'required|string' ]))->validate(); $model = $request->commentable_type::findOrFail($request->commentable_id); $commentClass = Config::get('comments.model'); $comment = new $commentClass; if (!Auth::check()) { $comment->guest_name = $request->guest_name; $comment->guest_email = $request->guest_email; } else { $comment->commenter()->associate(Auth::user()); } $comment->commentable()->associate($model); $comment->comment = $request->message; $comment->approved = !Config::get('comments.approval_required'); $comment->save(); return Redirect::to(URL::previous() . '#comment-' . $comment->getKey()); } /** * Updates the message of the comment. */ public function update(Request $request, Comment $comment) { Gate::authorize('edit-comment', $comment); Validator::make($request->all(), [ 'message' => 'required|string' ])->validate(); $comment->update([ 'comment' => $request->message ]); return Redirect::to(URL::previous() . '#comment-' . $comment->getKey()); } /** * Deletes a comment. */ public function destroy(Comment $comment) { Gate::authorize('delete-comment', $comment); if (Config::get('comments.soft_deletes') == true) { $comment->delete(); } else { $comment->forceDelete(); } return Redirect::back(); } /** * Creates a reply "comment" to a comment. */ public function reply(Request $request, Comment $comment) { Gate::authorize('reply-to-comment', $comment); Validator::make($request->all(), [ 'message' => 'required|string' ])->validate(); $commentClass = Config::get('comments.model'); $reply = new $commentClass; $reply->commenter()->associate(Auth::user()); $reply->commentable()->associate($comment->commentable); $reply->parent()->associate($comment); $reply->comment = $request->message; $reply->approved = !Config::get('comments.approval_required'); $reply->save(); return Redirect::to(URL::previous() . '#comment-' . $reply->getKey()); } }