Do you want the last person who published a page, or the last person that edited it?

Eduard Ichim

And that One is doing so many queries... so wanted to optimize it a little

Eduard Ichim

Yes but doing Versioned::get_by_stage() and in loop $page->Author() doesn't work I need to go in the loop $page->allVersions()->sort('ID DESC')->first()->Author()->FirstName

Eduard Ichim

Is there a way of doing SomePage::get()->filter(['SomePropertyThatReflectsPublished' => true])

Eduard Ichim

Ok I have the query like this, because I need all the published ~dates~ and the ::get()->byID() doesn't work for me...

  1. return Versioned::get_by_stage('Page', 'Live')
  2. ->filter([
  3. 'LastEdited:GreaterThan' => date('c', strtotime('-6 months'))
  4. ])
  5. ->sort('LastEdited DESC')
  6. ->limit(8);

I’d probably do something like:

  1. SomePage::get()->byID(2338)->Author()->FirstName

SomePage::get() gets you the latest version of all pages, ->byID(2338) gets the specific one you’re looking for from the collection, and then you get the Author’s FirstName