Ejemplo n.º 1
0
 /**
  * Show likes on a comment
  *
  * @param \App\Eloquent\Comment $comment
  * @return string
  */
 public function showCommentLikes($comment = null)
 {
     //No likes
     if ($comment->likes()->count() == 0) {
         //We return blank
         return '';
     }
     //Return comment likes
     return ' - <i class="fa fa-thumbs-up"></i> ' . $comment->likes()->count();
 }
 /**
  * Seeding likes on comments
  */
 public function seedLikesOnComments()
 {
     //Unguard model
     Model::unguard();
     $totalGenerated = 0;
     foreach (Comment::orderBYRaw('RAND()')->limit(100)->get() as $comment) {
         $users = User::orderByRaw('RAND()')->limit(mt_rand(1, 30))->get();
         //Create a new like on post by the user
         foreach ($users as $user) {
             $randDate = $this->faker->dateTimeBetween('-1years', 'now');
             $comment->likes()->create(['user_id' => $user->id, 'created_at' => $randDate, 'updated_at' => $randDate]);
         }
         $totalGenerated += $users->count();
     }
     echo $totalGenerated . ' likes created on comments';
     Model::reguard();
 }
Ejemplo n.º 3
0
 /**
  * Get a single comment and return it
  *
  * @param string $commentId
  * @return \App\Eloquent\Comment
  */
 public function getComment($commentId = '')
 {
     //Return comment
     return $this->comment->findOrFail($commentId);
 }