mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
$model->podcast->language_code
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user