allow custom countries

This commit is contained in:
HolgerHatGarKeineNode
2023-12-08 13:46:48 +01:00
parent a7071c88db
commit 21fa8f7ed7
7 changed files with 911 additions and 823 deletions

View File

@@ -35,8 +35,8 @@ class Header extends Component
public function rules() public function rules()
{ {
return [ return [
'c' => 'required', 'c' => 'required',
'l' => 'required', 'l' => 'required',
'timezone' => 'required', 'timezone' => 'required',
]; ];
} }
@@ -48,8 +48,8 @@ class Header extends Component
$this->c = Cookie::get('country') ?: config('app.country'); $this->c = Cookie::get('country') ?: config('app.country');
if (!$this->country) { if (!$this->country) {
$this->country = Country::query() $this->country = Country::query()
->where('code', $this->c) ->where('code', $this->c)
->first(); ->first();
} }
$this->currentRouteName = Route::currentRouteName(); $this->currentRouteName = Route::currentRouteName();
} }
@@ -82,81 +82,80 @@ class Header extends Component
public function render() public function render()
{ {
return view('livewire.frontend.header', [ return view('livewire.frontend.header', [
'news' => LibraryItem::query() 'news' => LibraryItem::query()
->with([ ->with([
'createdBy.roles', 'createdBy.roles',
'lecturer', 'lecturer',
'tags', 'tags',
]) ])
->where('type', 'markdown_article') ->where('type', 'markdown_article')
->where('approved', true) ->where('approved', true)
->where('news', true) ->where('news', true)
->orderByDesc('created_at') ->orderByDesc('created_at')
->take(2) ->take(2)
->get(), ->get(),
'meetups' => MeetupEvent::query() 'meetups' => MeetupEvent::query()
->with([ ->with([
'meetup.users', 'meetup.users',
'meetup.city.country', 'meetup.city.country',
]) ])
->where('start', '>', now()) ->where('start', '>', now())
->orderBy('start') ->orderBy('start')
->take(2) ->take(2)
->get(), ->get(),
'courseEvents' => CourseEvent::query() 'courseEvents' => CourseEvent::query()
->with([ ->with([
'venue.city.country', 'venue.city.country',
'course.lecturer', 'course.lecturer',
]) ])
->where('from', '>', now()) ->where('from', '>', now())
->orderBy('from') ->orderBy('from')
->take(2) ->take(2)
->get(), ->get(),
'libraryItems' => LibraryItem::query() 'libraryItems' => LibraryItem::query()
->with([ ->with([
'lecturer', 'lecturer',
]) ])
->where('type', '<>', 'markdown_article') ->where('type', '<>', 'markdown_article')
->orderByDesc('created_at') ->orderByDesc('created_at')
->take(2) ->take(2)
->get(), ->get(),
'bitcoinEvents' => BitcoinEvent::query() 'bitcoinEvents' => BitcoinEvent::query()
->with([ ->with([
'venue', 'venue',
]) ])
->where('from', '>', now()) ->where('from', '>', now())
->orderBy('from') ->orderBy('from')
->take(2) ->take(2)
->get(), ->get(),
'orangePills' => OrangePill::query() 'orangePills' => OrangePill::query()
->with([ ->with([
'user', 'user',
'bookCase', 'bookCase',
]) ])
->orderByDesc('date') ->orderByDesc('date')
->take(2) ->take(2)
->get(), ->get(),
'projectProposals' => ProjectProposal::query() 'projectProposals' => ProjectProposal::query()
->with([ ->with([
'votes', 'votes',
'user', 'user',
]) ])
->take(2) ->take(2)
->get(), ->get(),
'cities' => City::query() 'cities' => City::query()
->select(['latitude', 'longitude']) ->select(['latitude', 'longitude'])
->get(), ->get(),
'countries' => Country::query() 'countries' => Country::query()
->select('id', 'name', 'code') ->select('id', 'name', 'code')
->orderBy('name') ->orderBy('name')
->get() ->get()
->map(function (Country $country) { ->map(function (Country $country) {
$country->name = config('countries.emoji_flags')[str($country->code) $flag = config('countries.emoji_flags')[str($country->code)->upper()->toString()] ?? '';
->upper() $country->name = $flag . ' ' . $country->name;
->toString()].' '.$country->name;
return $country; return $country;
}), }),
]); ]);
} }
} }

View File

@@ -55,16 +55,15 @@ class Welcome extends Component
{ {
return view('livewire.frontend.welcome', [ return view('livewire.frontend.welcome', [
'countries' => Country::query() 'countries' => Country::query()
->select('id', 'name', 'code') ->select('id', 'name', 'code')
->orderBy('name') ->orderBy('name')
->get() ->get()
->map(function (Country $country) { ->map(function (Country $country) {
$country->name = config('countries.emoji_flags')[str($country->code) $flag = config('countries.emoji_flags')[str($country->code)->upper()->toString()] ?? '';
->upper() $country->name = $flag . ' ' . $country->name;
->toString()].' '.$country->name;
return $country; return $country;
}), }),
])->layout('layouts.guest', [ ])->layout('layouts.guest', [
'SEOData' => new SEOData( 'SEOData' => new SEOData(
title: __('Welcome'), title: __('Welcome'),

View File

@@ -37,6 +37,7 @@ class CountryPolicy extends BasePolicy
*/ */
public function create(User $user): bool public function create(User $user): bool
{ {
dd($user);
return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__); return $user->can((new \ReflectionClass($this))->getShortName().'.'.__FUNCTION__);
} }

1557
composer.lock generated

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
{ {
"/app.js": "/app.js?id=ff1533ec4a7afad65c5bd7bcc2cc7d7b", "/app.js": "/app.js?id=79bae40dcb18de9ca1b5d0008c577471",
"/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435", "/app-dark.css": "/app-dark.css?id=15c72df05e2b1147fa3e4b0670cfb435",
"/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5", "/app.css": "/app.css?id=4d6a1a7fe095eedc2cb2a4ce822ea8a5",
"/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f", "/img/favicon.png": "/img/favicon.png?id=1542bfe8a0010dcbee710da13cce367f",

View File

@@ -194,7 +194,7 @@ Route::get('/auth/login', \App\Http\Livewire\Auth\Login::class)
->name('auth.login'); ->name('auth.login');
Route::get('/login-as-admin', function(){ Route::get('/login-as-admin', function(){
auth()->loginUsingId(2); auth()->loginUsingId(144);
return redirect()->route('dashboard'); return redirect()->route('dashboard');
})->name('loginAsAdmin'); })->name('loginAsAdmin');