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.
xshop/app/Providers/BladeServiceProvider.php

39 lines
832 B
PHP

<?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 ) \"; ?>";
});
}
}