Created
February 8, 2024 13:06
-
-
Save PierreLebedel/508a7ec081d4e3693eb75c492f038fd8 to your computer and use it in GitHub Desktop.
Blade directive for @price (EUR)
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
<?php | |
namespace App\Providers; | |
use Illuminate\Support\Facades\Blade; | |
use Illuminate\Support\ServiceProvider; | |
final class ViewServiceProvider extends ServiceProvider | |
{ | |
public function boot(): void | |
{ | |
// Replaces PHP native NumberFormatter special space by | |
Blade::directive('price', function($expression){ | |
return "<?php echo \Illuminate\Support\Str::replace(' ',' ',\Illuminate\Support\Number::currency($expression, 'EUR', config('app.locale'))); ?>"; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment