Skip to content

Commit

Permalink
feat: Pagination registered in service provider
Browse files Browse the repository at this point in the history
  • Loading branch information
achyutkneupane committed Jan 29, 2024
1 parent 34611e8 commit 5f5bf9f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Ready to use Laravel Helpers",
"type": "library",
"license": "MIT",
"minimum-stability": "stable",
"minimum-stability": "dev",

"keywords": ["laravel", "helpers", "laravel-helpers", "nepal"],
"autoload": {
Expand Down Expand Up @@ -45,5 +45,12 @@
},
"require-dev": {
"phpunit/phpunit": "^7.0|^8.0|^9.0|^10.0"
},
"extra": {
"laravel": {
"providers": [
"AchyutN\\LaravelHelpers\\LaravelHelperProvider"
]
}
}
}
26 changes: 26 additions & 0 deletions src/LaravelHelperProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace AchyutN\LaravelHelpers;

use AchyutN\Pagination\CustomPaginator;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\ServiceProvider;

class LaravelHelperProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
$this->app->alias(CustomPaginator::class, LengthAwarePaginator::class);
}

/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}
2 changes: 1 addition & 1 deletion src/Pagination/CustomPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function toArray(): array
'data' => $this->items->toArray(),
'total' => $this->total(),
'perPage' => $this->perPage(),
'currentPage' => $this->currentPage(),
'page' => $this->currentPage(),

];
}
Expand Down

0 comments on commit 5f5bf9f

Please sign in to comment.