mirror of https://github.com/4xmen/xshop.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
840 B
PHTML
39 lines
840 B
PHTML
7 months ago
|
<?php
|
||
|
|
||
|
namespace App\Providers;
|
||
|
|
||
|
use Illuminate\Support\Facades\Blade;
|
||
|
use Illuminate\Support\ServiceProvider;
|
||
|
|
||
|
class BladeServiceProvider extends ServiceProvider
|
||
|
{
|
||
|
/**
|
||
|
* Register services.
|
||
|
*/
|
||
|
public function register(): void
|
||
|
{
|
||
|
//
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Bootstrap services.
|
||
|
*/
|
||
|
public function boot(): void
|
||
|
{
|
||
|
//
|
||
|
Blade::directive('paginated', function ($expression) {
|
||
|
|
||
|
return "<?php
|
||
|
|
||
|
\$items = $expression;
|
||
|
\$total = \$items->total();
|
||
|
\$currentPage = \$items->currentPage();
|
||
|
\$perPage = \$items->perPage();
|
||
|
\$from = (\$currentPage - 1) * \$perPage + 1;
|
||
|
\$to = min(\$currentPage * \$perPage, \$total);
|
||
|
|
||
|
echo \"(\$from | \$to | \$total) \"; ?>";
|
||
|
});
|
||
|
}
|
||
|
}
|