Files
einundzwanzig-portal/app/Http/Livewire/Library/LibraryTable.php
Benjamin Takats cf6afdcb43 add languages
2022-12-18 21:15:23 +01:00

47 lines
1.1 KiB
PHP

<?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 = '*';
protected $queryString = [
'currentTab' => ['except' => '*'],
];
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' => '*',
]
]);
foreach ($libraries as $library) {
$tabs->push([
'name' => $library->name,
]);
}
return view('livewire.library.library-table', [
'libraries' => $tabs,
]);
}
}