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:
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