Beispiel #1
0
 protected function createFakeCommentReply(Comment $comment)
 {
     $comment->replies()->create(['created_at' => $this->faker->dateTimeThisDecade, 'text' => $this->faker->text(512), 'user_id' => $this->getRandomUser()->getKey()]);
 }
 public function onCommentEdit(Comment $comment)
 {
     $notification = $comment->notifications()->first();
     $this->updateNotificationTargets($notification, $comment->text_source);
 }
 /**
  * @param  string  $id
  * @param  string  $type
  * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model
  */
 private function getObject($id, $type)
 {
     $id = \Hashids::decode($id);
     $id = current($id);
     switch ($type) {
         case 'content':
             return Content::findOrFail($id);
         case 'related':
             return ContentRelated::findOrFail($id);
         case 'entry':
             return Entry::findOrFail($id);
         case 'entry_reply':
             return EntryReply::findOrFail($id);
         case 'comment':
             return Comment::findOrFail($id);
         case 'comment_reply':
             return CommentReply::findOrFail($id);
     }
 }
Beispiel #4
0
 /**
  * Add new reply to given Comment object.
  *
  * @param  Request  $request
  * @param  Comment  $parent
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function addReply(Request $request, $parent)
 {
     $this->validate($request, CommentReply::rules());
     $content = $parent->content;
     if (Auth::user()->isBanned($content->group)) {
         return Response::json(['status' => 'error', 'error' => 'Zostałeś zbanowany w tej grupie']);
     }
     $comment = new CommentReply(['text' => Input::get('text')]);
     $comment->user()->associate(Auth::user());
     $parent->replies()->save($comment);
     $replies = view('comments.replies', ['replies' => $parent->replies])->render();
     return Response::json(['status' => 'ok', 'replies' => $replies]);
 }
<?php

use Strimoid\Models\Comment;
$builder = Comment::with(['user' => function ($q) {
    $q->select(['id', 'avatar', 'name']);
}, 'content' => function ($q) {
    $q->select(['id', 'title']);
}])->fromDaysAgo(3);
if (isset($group) && $group instanceof Strimoid\Models\Group) {
    $builder->where('group_id', $group->getKey());
}
$popularComments = $builder->remember(60)->orderBy('uv', 'desc')->take(5)->get();
?>

<div class="well popular_contents_widget">
    <h5>@lang('common.popular comments')</h5>

    <ul class="media-list popular_contents_list">
        @foreach ($popularComments as $comment)
        <?php 
$text = preg_replace('/<a class="show_spoiler">(.*?)<\\/a>/s', '', $comment->text);
$text = preg_replace('/<span class="spoiler">(.*?)<\\/span>/s', '', $text);
$text = strip_tags($text);
$url = route('content_comments', ['content' => $comment->content]) . '#' . $comment->hashId();
?>
        <li class="media">
            <a class="pull-left" href="{!! $url !!}" rel="nofollow">
                <img src="{!! $comment->user->getAvatarPath(40, 40) !!}" alt="{!! $comment->user->name !!}" style="height: 40px; width: 40px; border-radius: 3px;">
            </a>
            <div class="media-body">
                <h6 class="media-heading"><a href="{!! $url !!}">{!! Str::limit($text, 100) !!}</a></h6>
 /**
  * Remove comment.
  *
  * @param Comment $comment Comment instance
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function remove($comment)
 {
     if (!$comment->canRemove()) {
         abort(403);
     }
     $comment->delete();
     return response()->json(['status' => 'ok']);
 }