Sequenzia/app/models/Post/CommentMethods.php
2013-10-26 18:06:58 -05:00

14 lines
382 B
PHP
Executable File

<?php
trait PostCommentMethods
{
public function recent_comments()
{
$recent = new Rails\ActiveRecord\Collection();
# reverse_order to fetch last 6 comments
# reversed in the last to return from lowest id
if ($this->comments) {
$recent->merge(array_slice($this->comments->members(), -6));
}
return $recent;
}
}