/** * Get the last item from the collection according to the obtained conditions. * * @param Query $query * @return mixed|null */ public function lastByQuery(Query $query) { $last = $this->last(function ($key, $item) use($query) { return $query->filteredByQuery($item); }); return $last; }