example.com
, который можно вызвать для создания куки .example.com
? $category
public function getBlog(Request $request, $category)
, которая будет ловить /блог/название_категорииprotected $middleware = [
'web' => [ \App\Http\Middleware\Locale::class],
];
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class
?protected $middleware = [
'web' => [ \App\Http\Middleware\Locale::class],
];
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Session;
class Locale
{
public function handle($request, Closure $next)
{
$raw_locale = Session::get('locale');
if (in_array($raw_locale, Config::get('app.locales'))) {
$locale = $raw_locale;
}
else $locale = Config::get('app.locale');
App::setLocale($locale);
return $next($request);
}
}
Lang::setLocale('ru');
Route::get('setlocale/{locale}', function ($locale) {
if (in_array($locale, \Config::get('app.locales'))) {
Session::put('locale', $locale);
locales
в config/app.php
?