forked from spatie/laravel-paginateroute
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3904428
commit ea444ec
Showing
13 changed files
with
173 additions
and
116 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,6 @@ | ||
# Changelog | ||
|
||
All Notable changes to `:package_name` will be documented in this file | ||
All Notable changes to `spatie/laravel-paginateroute` will be documented in this file | ||
|
||
## NEXT - YYYY-MM-DD | ||
|
||
### Added | ||
- Nothing | ||
|
||
### Deprecated | ||
- Nothing | ||
|
||
### Fixed | ||
- Nothing | ||
|
||
### Removed | ||
- Nothing | ||
|
||
### Security | ||
- Nothing | ||
## 2015-06-03 | ||
- First release! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2015 :author_name <:author_email> | ||
Copyright (c) 2015 Sebastian De Deyne <[email protected]> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'page' => 'page', | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'page' => 'page', | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'page' => 'pagina', | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Spatie\PaginateRoute; | ||
|
||
use Route; | ||
|
||
class PaginateRoute | ||
{ | ||
/** | ||
* Register the Route::paginate macro | ||
* | ||
* @return void | ||
*/ | ||
public function registerMacros() | ||
{ | ||
// Unfortunately we can't do this in the service provider since routes are booted first | ||
app('translator')->addNamespace('paginateroute', __DIR__.'/../resources/lang'); | ||
|
||
$pageName = trans('paginateroute::paginateroute.page'); | ||
|
||
Route::macro('paginate', function ($uri, $action) use ($pageName) { | ||
Route::group( | ||
['middleware' => 'Spatie\PaginateRoute\SetPageMiddleware'], | ||
function () use ($pageName, $uri, $action) { | ||
Route::get($uri, $action); | ||
Route::get($uri.'/'.$pageName.'/{page}', $action)->where('page', '[0-9]+'); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Spatie\PaginateRoute; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class PaginateRouteServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Perform post-registration booting of services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->publishes([ | ||
__DIR__.'/../resources/lang' => base_path('resources/lang/vendor/paginateroute'), | ||
]); | ||
} | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app->instance('paginateroute', new PaginateRoute); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Spatie\PaginateRoute; | ||
|
||
use Closure; | ||
use Illuminate\Pagination\Paginator; | ||
use Route; | ||
|
||
class SetPageMiddleware | ||
{ | ||
/** | ||
* Set the current page based on the page route parameter before the route's action is executed. | ||
* | ||
* @return \Illuminate\Http\Request | ||
*/ | ||
public function handle($request, Closure $next) | ||
{ | ||
$page = Route::getCurrentRoute()->parameter('page', 1); | ||
|
||
Paginator::currentPageResolver(function () use ($page) { | ||
return $page; | ||
}); | ||
|
||
return $next($request); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.