Phosphorum\Models\PostsRepliesHistory::findLast PHP Method

findLast() public static method

public static findLast ( PostsReplies $reply ) : Phalcon\Mvc\Model\ResultsetInterface | Phalcon\Mvc\Model\Resultset\Simple
$reply PostsReplies
return Phalcon\Mvc\Model\ResultsetInterface | Phalcon\Mvc\Model\Resultset\Simple
    public static function findLast(PostsReplies $reply)
    {
        return self::find(['posts_replies_id = ?0', 'bind' => [$reply->id], 'order' => 'created_at DESC']);
    }

Usage Example

Beispiel #1
0
 public function getDifference()
 {
     $history = PostsRepliesHistory::findLast($this);
     if (!$history->valid()) {
         return false;
     }
     if ($history->count() > 1) {
         $history = $history->offsetGet(1);
     } else {
         $history = $history->getFirst();
     }
     /** @var PostsRepliesHistory $history */
     $b = explode("\n", $history->content);
     $diff = new Diff($b, explode("\n", $this->content), []);
     $difference = $diff->render(new SideBySide());
     return $difference;
 }