mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
podcast episodes view added
This commit is contained in:
@@ -25,8 +25,8 @@ class LibraryTable extends Component
|
||||
|
||||
protected $queryString = [
|
||||
'currentTab' => ['except' => '*'],
|
||||
'filters' => ['except' => ''],
|
||||
'search' => ['except' => ''],
|
||||
'filters' => ['except' => ''],
|
||||
'search' => ['except' => ''],
|
||||
];
|
||||
|
||||
public function loadMore()
|
||||
@@ -54,7 +54,7 @@ class LibraryTable extends Component
|
||||
|
||||
public function render()
|
||||
{
|
||||
$shouldBePublic = ! $this->isLecturerPage;
|
||||
$shouldBePublic = !$this->isLecturerPage;
|
||||
$libraries = \App\Models\Library::query()
|
||||
->whereNull('parent_id')
|
||||
->where('is_public', $shouldBePublic)
|
||||
@@ -84,32 +84,32 @@ class LibraryTable extends Component
|
||||
}
|
||||
|
||||
return view('livewire.library.library-table', [
|
||||
'libraries' => $tabs,
|
||||
'libraries' => $tabs,
|
||||
'libraryItems' => LibraryItem::query()
|
||||
->with([
|
||||
'lecturer',
|
||||
'tags',
|
||||
])
|
||||
->when($this->search, fn ($query) => $query
|
||||
->when($this->search, fn($query) => $query
|
||||
->where('name', 'ilike', '%'.$this->search.'%')
|
||||
->orWhere(fn ($query) => $query
|
||||
->orWhere(fn($query) => $query
|
||||
->when(count($searchTags) > 0 && count($this->filters) < 1,
|
||||
fn ($query) => $query->whereHas('tags',
|
||||
fn ($query) => $query->whereIn('tags.id', $searchTags)))
|
||||
fn($query) => $query->whereHas('tags',
|
||||
fn($query) => $query->whereIn('tags.id', $searchTags)))
|
||||
)
|
||||
)
|
||||
->when($this->currentTab !== '*', fn ($query) => $query
|
||||
->when($this->currentTab !== '*', fn($query) => $query
|
||||
->whereHas('libraries',
|
||||
fn ($query) => $query
|
||||
fn($query) => $query
|
||||
->where('libraries.name', $this->currentTab)
|
||||
)
|
||||
)
|
||||
->when(isset($this->filters['tag']), fn ($query) => $query->whereHas('tags',
|
||||
fn ($query) => $query->whereIn('tags.id', $this->filters['tag'])))
|
||||
->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']))
|
||||
fn($query) => $query->whereIn('language_code', $this->filters['language']))
|
||||
->whereHas('libraries',
|
||||
fn ($query) => $query->where('libraries.is_public', $shouldBePublic))
|
||||
fn($query) => $query->where('libraries.is_public', $shouldBePublic))
|
||||
->orderByDesc('library_items.created_at')
|
||||
->paginate($this->perPage),
|
||||
])->layout('layouts.app', [
|
||||
|
||||
50
app/Http/Livewire/Library/PodcastEpisodesTable.php
Normal file
50
app/Http/Livewire/Library/PodcastEpisodesTable.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Library;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\Episode;
|
||||
use Livewire\Component;
|
||||
|
||||
class PodcastEpisodesTable extends Component
|
||||
{
|
||||
public Country $country;
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public $perPage = 9;
|
||||
|
||||
public $currentTab = '*';
|
||||
|
||||
protected $queryString = [
|
||||
'filters' => ['except' => ''],
|
||||
'search' => ['except' => ''],
|
||||
];
|
||||
|
||||
public function loadMore()
|
||||
{
|
||||
$this->perPage += 9;
|
||||
}
|
||||
|
||||
public function resetFiltering($isLecturerPage = false)
|
||||
{
|
||||
return to_route('library.table.podcastsEpisodes', ['country' => $this->country]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.library.podcast-episodes-table', [
|
||||
'episodes' => Episode::query()
|
||||
->with(['podcast'])
|
||||
->when($this->search,
|
||||
fn($query, $search) => $query
|
||||
->where('data->title', 'ilike', "%{$search}%")
|
||||
->orWhere('data->description', 'ilike', "%{$search}%")
|
||||
)
|
||||
->orderByDesc('data->datePublished')
|
||||
->paginate($this->perPage),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user