我在尝试使用新设置的区域设置为我的路线添加前缀时遇到了问题。当我从控制器或路由闭包返回 app()->getLocale() 时,它会正确返回新设置的区域设置,但是当我将其放入路由前缀时,我会得到默认的“en”。就我而言,新的语言环境是“ar”。
这是我在 web.php 中的代码
<?php
//Request to put the choosen locale into the session
Route::get('locale/{locale}', function($locale) {
session()->put('userLocale', $locale);
return redirect(app()->getLocale());
});
//Group of routes that are supposed to be prefixed with new set locale 'ar'
Route::group(['prefix' => app()->getLocale(), 'middleware' => 'locale'], function() {
Route::get('/', function() {
return app()->getLocale();
});
});
Run Code Online (Sandbox Code Playgroud)
这是中间件:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
class Locale
{
protected $app;
public function __construct(Application $app)
{
$this->app = $app;
}
/**
* Handle …Run Code Online (Sandbox Code Playgroud) I'm new to Firebase Cloud Messaging and I need to implement notifications in my webapp. If the browser requests notification for the first time there is no error occurred and the token fetched successfuly. But if I delete the notification from the browser parametre (I use Chrome) and ask for permission again, it shows me an error in the console.
DELETE https://fcmregistrations.googleapis.com/v1/projects/teak-perigee-*****/registrations/dcVW8MdcapIy5CrSqGutkj:APA91bFoslZEsjgIk16CUfol*****************
FirebaseError: Messaging: A problem occured while unsubscribing the user from FCM: FirebaseError: Messaging: A problem occured while unsubscribing …Run Code Online (Sandbox Code Playgroud)