/** * Register the service provider. * * @return void */ public function register() { Paginator::currentPathResolver(function () { return $this->app['slim']->request->getResourceUri(); }); Paginator::currentPageResolver(function ($pageName = 'page') { return $this->app['slim']->request->params($pageName); }); }
/** * Register the service provider. * * @return void */ public function register() { Paginator::currentPathResolver(function () { return $this->app['request']->url(); }); Paginator::currentPageResolver(function () { return $this->app['request']->input('page'); }); }
/** * Register the service provider. * * @return void */ public function register() { Paginator::currentPathResolver(function () { return $this->app['request']->url(); }); Paginator::currentPageResolver(function ($pageName = 'page') { $page = $this->app['request']->input($pageName); if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) { return $page; } return 1; }); }
/** * Register the service provider. * * @return void */ public static function register() { Paginator::currentPathResolver(function () { return $GLOBALS['APPLICATION']->getCurPage(); }); Paginator::currentPageResolver(function ($pageName = 'page') { $page = $_GET[$pageName]; if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) { return $page; } return 1; }); }
$app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware()); $app->get('/', function () { echo '<a href="database">Database</a> | <a href="array">Non-database</a>'; }); // This route demonstrates an example of using the paginator with the illuminate\database component $app->get('/database', function () { // Set up the database connection--see the database component for more info $capsule = new Capsule(); $capsule->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'illuminate_non_laravel', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']); $capsule->setEventDispatcher(new Dispatcher(new Container())); $capsule->setAsGlobal(); $capsule->bootEloquent(); // End of database setup // Set up a current path resolver so the paginator can generate proper links Paginator::currentPathResolver(function () { return isset($_SERVER['REQUEST_URI']) ? strtok($_SERVER['REQUEST_URI'], '?') : '/'; }); // Set up a current page resolver Paginator::currentPageResolver(function ($pageName = 'page') { $page = isset($_REQUEST[$pageName]) ? $_REQUEST[$pageName] : 1; return $page; }); $perPage = 5; // results per page $columns = ['*']; // (optional, defaults to *) array of columns to retrieve from database $pageName = 'page'; // (optional, defaults to 'page') query string parameter name for the page number if (User::all()->count() <= $perPage) { exit("Need more than <strong>{$perPage}</strong> users in your <i>illuminate_non_laravel</i> database to see this work"); }
/** * Register the service provider. * * @return void */ public function register() { /* * Register all third party packages first. */ $this->app->register(\TwigBridge\ServiceProvider::class); $this->app->register(\Laravel\Scout\ScoutServiceProvider::class); $this->app->register(\Collective\Html\HtmlServiceProvider::class); $this->app->register(\Intervention\Image\ImageServiceProvider::class); $this->app->register(\TeamTNT\Scout\TNTSearchScoutServiceProvider::class); if (env('APP_DEBUG')) { $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class); } // Register bindings. foreach (array_merge($this->bindings, config('streams.bindings', [])) as $abstract => $concrete) { $this->app->bind($abstract, $concrete); } // Register singletons. foreach (array_merge($this->singletons, config('streams.singletons', [])) as $abstract => $concrete) { $this->app->singleton($abstract, $concrete); } // Register streams other providers. foreach (array_merge($this->providers, config('streams.providers', [])) as $provider) { $this->app->register($provider); } // Register commands. $this->commands(array_merge($this->commands, config('streams.commands', []))); /* @var Schedule $schedule */ $schedule = $this->app->make(Schedule::class); foreach (array_merge($this->schedule, config('streams.schedule', [])) as $frequency => $commands) { foreach (array_filter($commands) as $command) { if (str_contains($frequency, ' ')) { $schedule->command($command)->cron($frequency); } else { $schedule->command($command)->{camel_case($frequency)}(); } } } /* * Change the default language path so * that there MUST be a prefix hint. */ $this->app->singleton('path.lang', function () { return realpath(__DIR__ . '/../resources/lang'); }); /* * Register the path to the streams platform. * This is handy for helping load other streams things. */ $this->app->instance('streams.path', $this->app->make('path.base') . '/vendor/anomaly/streams-platform'); /* * If we don't have an .env file we need to head * to the installer (unless that's where we're at). */ if (!env('INSTALLED') && $this->app->make('request')->segment(1) !== 'installer') { $this->app->make('router')->any('{url?}', function (Redirector $redirector) { return $redirector->to('installer'); })->where(['url' => '(.*)']); return; } /** * Correct path for Paginator. */ Paginator::currentPathResolver(function () { return $this->app->make(UrlGenerator::class)->current(); }); /* * Register system routes. */ $this->app->make('router')->post('form/handle/{key}', 'Anomaly\\Streams\\Platform\\Http\\Controller\\FormController@handle'); $this->app->make('router')->get('entry/handle/restore/{addon}/{namespace}/{stream}/{id}', 'Anomaly\\Streams\\Platform\\Http\\Controller\\EntryController@restore'); $this->app->make('router')->get('entry/handle/export/{addon}/{namespace}/{stream}', 'Anomaly\\Streams\\Platform\\Http\\Controller\\EntryController@export'); }