count(); return self::paginator($this->forPage($page, $pageSize), $total, $pageSize, $page, [ 'path' => Paginator::resolveCurrentPath(), 'pageName' => 'page', ]); } protected static function paginator($items, $total, $perPage, $currentPage, $options) { return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact( 'items', 'total', 'perPage', 'currentPage', 'options' )); } public function nonExpired() { return $this->filter( function ($ad) { return $ad->where('finish_at', '>', Carbon::now()); } ); } }