Devise\Pages\PagesRepository::getLivePageVersionById PHP Method

getLivePageVersionById() public method

Get the live version of this page by id
public getLivePageVersionById ( [type] $page, [type] $pageVersionId ) : [type]
$page [type]
$pageVersionId [type]
return [type]
    public function getLivePageVersionById($page, $pageVersionId)
    {
        $now = $this->now;
        $version = $page->versions()->with('fields')->where('starts_at', '<', $now)->where(function ($query) use($now) {
            $query->where('ends_at', '>', $now);
            $query->orWhereNull('ends_at');
        })->where('id', '=', $pageVersionId)->orderBy('starts_at', 'DESC');
        if ($page->ab_testing_enabled) {
            $version = $version->where('ab_testing_amount', '>', 0);
        }
        return $version->first();
    }