Created
January 27, 2022 16:02
-
-
Save relliv/cd6342c81114266848c1059aba7324e1 to your computer and use it in GitHub Desktop.
Laravel Carbon localize middleware
This file contains hidden or 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\Http\Middleware; | |
| use Closure; | |
| use Illuminate\Contracts\Foundation\Application; | |
| use Illuminate\Http\Request; | |
| use Carbon\Carbon; | |
| class Localize | |
| { | |
| public function __construct( | |
| private Application $app, | |
| ) {} | |
| public function handle(Request $request, Closure $next) | |
| { | |
| Carbon::setLocale($this->app->getLocale()); | |
| return $next($request); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, we have to define in
AppServiceProvider