/** * Bootstrap the Application events. * * @return void */ public function boot() { $db = $this->app['db']; $events = $this->app['events']; // Setup the ORM Model. Model::setConnectionResolver($db); Model::setEventDispatcher($events); // Setup the (basic) Model. BasicModel::setConnectionResolver($db); }
/** * Get a Paginator only supporting simple next and previous links. * * This is more efficient on larger data-sets, etc. * * @param int $perPage * @param array $columns * @return \Pagination\Paginator */ public function simplePaginate($perPage = null, $columns = array('*')) { // Get the Pagination Factory instance. $paginator = $this->connection->getPaginator(); $perPage = $perPage ?: $this->model->getPerPage(); $page = $paginator->getCurrentPage(); $query = $this->skip(($page - 1) * $perPage)->take($perPage + 1); // Retrieve the results from database. $results = $query->get($columns); return $paginator->make($results, $perPage); }
/** * Set a model instance for the model being queried. * * @param \Nova\Database\ORM\Model $model * @return \Nova\Database\ORM\Builder */ public function setModel(Model $model) { $this->model = $model; $this->query->from($model->getTable()); return $this; }
/** * Bootstrap the application events. * * @return void */ public function boot() { SimpleModel::setConnectionResolver($this->app['db']); Model::setConnectionResolver($this->app['db']); Model::setEventDispatcher($this->app['events']); }