Here is what i'm trying to do:
I'm implementing a version_id in my vendors table. I'm trying to construct a query to get the index page working. So i'm looking to get all of the vendors from my database that have the latest version_id (max('version_id'). Can't seem to figure it out. Here is what I have so far:
$vendors = $this->account->vendors()->where('version_id', max(version_id))
->orderBy($this->orderBy, $this->sortBy)
->paginate($this->display_per_page);
I tried this before, but it also gives me errors:
$vendors = $this->account->vendors()->max('version_id')
->orderBy($this->orderBy, $this->sortBy)
->paginate($this->display_per_page);
It works if I just have this:
$vendors = $this->account->vendors()
->orderBy($this->orderBy, $this->sortBy)
->paginate($this->display_per_page);
Been looking online but I only find suggestions for queries with joins and such, which is not what i'm looking for. Any help is appreciated!