diff --git a/app/Http/Livewire/Library/LibraryTable.php b/app/Http/Livewire/Library/LibraryTable.php index f7578b1d..89a552bf 100644 --- a/app/Http/Livewire/Library/LibraryTable.php +++ b/app/Http/Livewire/Library/LibraryTable.php @@ -6,7 +6,6 @@ use App\Models\Country; use App\Models\Library; use App\Models\LibraryItem; use App\Models\Tag; -use Illuminate\Pagination\LengthAwarePaginator; use Livewire\Component; use RalphJSmit\Laravel\SEO\Support\SEOData; @@ -83,7 +82,7 @@ class LibraryTable extends Component } return view('livewire.library.library-table', [ - 'libraries' => $tabs, + 'libraries' => $tabs, 'libraryItems' => LibraryItem::query() ->with([ 'lecturer', @@ -103,8 +102,10 @@ class LibraryTable extends Component ->where('libraries.name', $this->currentTab) ) ) - ->when(count($this->filters) > 0, fn($query) => $query->whereHas('tags', - fn($query) => $query->whereIn('tags.id', $this->filters))) + ->when(isset($this->filters['tag']), fn($query) => $query->whereHas('tags', + fn($query) => $query->whereIn('tags.id', $this->filters['tag']))) + ->when(isset($this->filters['language']), + fn($query) => $query->whereIn('language_code', $this->filters['language'])) ->whereHas('libraries', fn($query) => $query->where('libraries.is_public', $shouldBePublic)) ->orderByDesc('library_items.created_at') diff --git a/app/Http/Livewire/Library/SearchByTagComponent.php b/app/Http/Livewire/Library/SearchByTagComponent.php index b9deee91..50286e11 100644 --- a/app/Http/Livewire/Library/SearchByTagComponent.php +++ b/app/Http/Livewire/Library/SearchByTagComponent.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire\Library; +use App\Models\LibraryItem; use App\Models\Tag; use Livewire\Component; @@ -11,7 +12,7 @@ class SearchByTagComponent extends Component public array $filters = []; protected $queryString = [ - 'filters' => ['except' => ''], + 'filters' => ['except' => ''], ]; public function render() @@ -21,19 +22,29 @@ class SearchByTagComponent extends Component ->getName() !== 'library.table.lecturer'; return view('livewire.library.search-by-tag-component', [ - 'tags' => Tag::query() - ->with([ - 'libraryItems.libraries', - 'libraryItems.lecturer', - ]) - ->withCount([ - 'libraryItems', - ]) - ->where('type', 'library_item') - ->whereHas('libraryItems.libraries', fn($query) => $query->where('is_public', $shouldBePublic)) - ->orderByDesc('library_items_count') - ->orderBy('tags.id') - ->get(), + 'languages' => LibraryItem::query() + ->pluck('language_code') + ->unique() + ->sort() + ->map(fn($item) => str($item) + ->before('_') + ->toString()) + ->values() + ->toArray(), + 'tags' => Tag::query() + ->with([ + 'libraryItems.libraries', + 'libraryItems.lecturer', + ]) + ->withCount([ + 'libraryItems', + ]) + ->where('type', 'library_item') + ->whereHas('libraryItems.libraries', + fn($query) => $query->where('is_public', $shouldBePublic)) + ->orderByDesc('library_items_count') + ->orderBy('tags.id') + ->get(), ]); } } diff --git a/app/Nova/Episode.php b/app/Nova/Episode.php index b46e0296..b6ff79fa 100644 --- a/app/Nova/Episode.php +++ b/app/Nova/Episode.php @@ -53,7 +53,9 @@ class Episode extends Resource 'episode_id' => $model->id, 'name' => $model->data['title'], 'type' => 'podcast_episode', - 'language_code' => $model->podcast->language_code, + 'language_code' => str($model->podcast->language_code) + ->before('-') + ->toString(), 'value' => null, 'excerpt' => $model->data['description'], 'subtitle' => $model->data['description'], diff --git a/resources/views/livewire/frontend/header.blade.php b/resources/views/livewire/frontend/header.blade.php index b94d06c6..c68f9742 100644 --- a/resources/views/livewire/frontend/header.blade.php +++ b/resources/views/livewire/frontend/header.blade.php @@ -110,6 +110,7 @@ option-value="language" /> + @auth
@else @@ -128,16 +129,16 @@+
{{ __('Choose your city, search for courses in the surrounding area and select a topic that suits you.') }}
+
{{ __('Choose a topic that is right for you.') }}