mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
split into modules
This commit is contained in:
46
app/Http/Livewire/Library/LibraryTable.php
Normal file
46
app/Http/Livewire/Library/LibraryTable.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Library;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\Podcast;
|
||||
use Livewire\Component;
|
||||
|
||||
class LibraryTable extends Component
|
||||
{
|
||||
public Country $country;
|
||||
|
||||
public $currentTab = 'Alle';
|
||||
|
||||
protected $queryString = [
|
||||
'currentTab' => ['except' => 'alle'],
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$shouldBePublic = request()
|
||||
->route()
|
||||
->getName() !== 'library.table.lecturer';
|
||||
if (!$shouldBePublic && !auth()->user()->is_lecturer) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$libraries = \App\Models\Library::query()
|
||||
->where('is_public', $shouldBePublic)
|
||||
->get();
|
||||
$tabs = collect([
|
||||
[
|
||||
'name' => 'Alle',
|
||||
]
|
||||
]);
|
||||
foreach ($libraries as $library) {
|
||||
$tabs->push([
|
||||
'name' => $library->name,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('livewire.library.library-table', [
|
||||
'libraries' => $tabs,
|
||||
]);
|
||||
}
|
||||
}
|
||||
37
app/Http/Livewire/Library/SearchByTagComponent.php
Normal file
37
app/Http/Livewire/Library/SearchByTagComponent.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Library;
|
||||
|
||||
use App\Models\Tag;
|
||||
use Livewire\Component;
|
||||
|
||||
class SearchByTagComponent extends Component
|
||||
{
|
||||
public string $country = 'de';
|
||||
public ?array $table = [];
|
||||
|
||||
protected $queryString = [
|
||||
'table',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$shouldBePublic = request()
|
||||
->route()
|
||||
->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))
|
||||
->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user