mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
fixes #7
This commit is contained in:
@@ -45,13 +45,13 @@ class Header extends Component
|
||||
{
|
||||
$this->timezone = config('app.user-timezone');
|
||||
$this->l = Cookie::get('lang') ?: config('app.locale');
|
||||
$this->c = Cookie::get('country') ?: config('app.country');
|
||||
if (!$this->country) {
|
||||
$this->country = Country::query()
|
||||
->where('code', $this->c)
|
||||
->first();
|
||||
}
|
||||
$this->currentRouteName = Route::currentRouteName();
|
||||
$this->c = $this->country->code;
|
||||
}
|
||||
|
||||
public function updatedTimezone($value)
|
||||
@@ -65,6 +65,7 @@ class Header extends Component
|
||||
|
||||
public function updatedC($value)
|
||||
{
|
||||
Cookie::queue('country', $value, 60 * 24 * 365);
|
||||
$url = str(request()->header('Referer'))->explode('/');
|
||||
$url[3] = $value;
|
||||
|
||||
@@ -73,15 +74,13 @@ class Header extends Component
|
||||
|
||||
public function updatedL($value)
|
||||
{
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
Cookie::queue('lang', $value, 60 * 24 * 365);
|
||||
|
||||
return redirect(request()->header('Referer'));
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
|
||||
return view('livewire.frontend.header', [
|
||||
'news' => LibraryItem::query()
|
||||
->with([
|
||||
@@ -137,10 +136,13 @@ class Header extends Component
|
||||
->orderByDesc('date')
|
||||
->take(2)
|
||||
->get(),
|
||||
'projectProposals' => ProjectProposal::query()->with([
|
||||
'votes',
|
||||
'user',
|
||||
])->get(),
|
||||
'projectProposals' => ProjectProposal::query()
|
||||
->with([
|
||||
'votes',
|
||||
'user',
|
||||
])
|
||||
->take(2)
|
||||
->get(),
|
||||
'cities' => City::query()
|
||||
->select(['latitude', 'longitude'])
|
||||
->get(),
|
||||
|
||||
@@ -26,6 +26,9 @@ class Welcome extends Component
|
||||
public function mount()
|
||||
{
|
||||
$this->l = Cookie::get('lang') ?: config('app.locale');
|
||||
$this->c = Cookie::get('country') ?: config('app.country');
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
Cookie::queue('country', $this->c, 60 * 24 * 365);
|
||||
}
|
||||
|
||||
public function updated($property, $value)
|
||||
@@ -43,14 +46,13 @@ class Welcome extends Component
|
||||
}
|
||||
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
Cookie::queue('country', $this->c, 60 * 24 * 365);
|
||||
|
||||
return to_route('welcome', ['c' => $c, 'l' => $l]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
Cookie::queue('lang', $this->l, 60 * 24 * 365);
|
||||
|
||||
return view('livewire.frontend.welcome', [
|
||||
'countries' => Country::query()
|
||||
->select('id', 'name', 'code')
|
||||
|
||||
@@ -12,6 +12,7 @@ class EncryptCookies extends Middleware
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'lang',
|
||||
'country',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@ class SetTimezoneMiddleware
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
App::setLocale(Cookie::get('lang') ?: config('app.locale'));
|
||||
if ($request->country) {
|
||||
config([
|
||||
'app.country' => $request->country,
|
||||
]);
|
||||
Cookie::queue('country', $request->country, 60 * 24 * 365);
|
||||
}
|
||||
if ($request->user()
|
||||
&& $timezone = $request->user()->timezone
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user