public static findLast ( |
||
$post | ||
return | Phalcon\Mvc\Model\ResultsetInterface | Phalcon\Mvc\Model\Resultset\Simple |
public static function findLast(Posts $post)
{
return self::find(['posts_id = ?0', 'bind' => [$post->id], 'order' => 'created_at DESC']);
}
public function getDifference() { $history = PostsHistory::findLast($this); if (!$history->valid()) { return false; } if ($history->count() > 1) { $history = $history->offsetGet(1); } else { $history = $history->getFirst(); } /** @var PostsHistory $history */ $b = explode("\n", $history->content); $diff = new Diff($b, explode("\n", $this->content), []); $difference = $diff->render(new SideBySide()); return $difference; }