mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-13 06:56:48 +00:00
lecturer landing pages added
This commit is contained in:
44
app/Http/Livewire/School/LecturerLandingPage.php
Normal file
44
app/Http/Livewire/School/LecturerLandingPage.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\School;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\CourseEvent;
|
||||
use App\Models\Lecturer;
|
||||
use Livewire\Component;
|
||||
|
||||
class LecturerLandingPage extends Component
|
||||
{
|
||||
public Lecturer $lecturer;
|
||||
public Country $country;
|
||||
|
||||
public ?int $year = null;
|
||||
public ?int $activeEvent = null;
|
||||
|
||||
protected $queryString = ['year'];
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.school.lecturer-landing-page', [
|
||||
'courseEvents' => CourseEvent::query()
|
||||
->get(),
|
||||
'events' => CourseEvent::query()
|
||||
->whereHas('course', function ($query) {
|
||||
$query->where('lecturer_id', $this->lecturer->id);
|
||||
})
|
||||
->get()
|
||||
->map(fn($event) => [
|
||||
'id' => $event->id,
|
||||
'startDate' => $event->from,
|
||||
'endDate' => $event->to,
|
||||
'location' => $event->course->name,
|
||||
'description' => $event->venue->name,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function showEvent($id)
|
||||
{
|
||||
$this->activeEvent = $id;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class LecturerTable extends DataTableComponent
|
||||
->collapseOnMobile(),
|
||||
Column::make('')
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.lectures.action')->withRow($row)
|
||||
fn($row, Column $column) => view('columns.lectures.action')->withRow($row)->withCountry($this->country)
|
||||
),
|
||||
|
||||
];
|
||||
@@ -77,18 +77,30 @@ class LecturerTable extends DataTableComponent
|
||||
]);
|
||||
}
|
||||
|
||||
public function lecturerSearch($id)
|
||||
public function lecturerSearch($id, $event = true)
|
||||
{
|
||||
$lecturer = Lecturer::query()->find($id);
|
||||
|
||||
return to_route('school.table.event', [
|
||||
'#table',
|
||||
'country' => $this->country,
|
||||
'table' => [
|
||||
'filters' => [
|
||||
'dozent' => $lecturer->id,
|
||||
],
|
||||
]
|
||||
]);
|
||||
if ($event) {
|
||||
return to_route('school.table.event', [
|
||||
'#table',
|
||||
'country' => $this->country,
|
||||
'table' => [
|
||||
'filters' => [
|
||||
'dozent' => $lecturer->id,
|
||||
],
|
||||
]
|
||||
]);
|
||||
} else {
|
||||
return to_route('library.table.libraryItems', [
|
||||
'#table',
|
||||
'country' => $this->country,
|
||||
'table' => [
|
||||
'filters' => [
|
||||
'lecturer_id' => $lecturer->id,
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
|
||||
use Spatie\LaravelOptions\Options;
|
||||
|
||||
class LibraryItemTable extends DataTableComponent
|
||||
@@ -43,6 +44,11 @@ class LibraryItemTable extends DataTableComponent
|
||||
public function filters(): array
|
||||
{
|
||||
return [
|
||||
TextFilter::make(__('By lecturer'), 'lecturer_id')
|
||||
->hiddenFromMenus()
|
||||
->filter(function (Builder $builder, string $value) {
|
||||
$builder->where('library_items.lecturer_id', '=', $value);
|
||||
}),
|
||||
MultiSelectFilter::make('Tag')
|
||||
->options(
|
||||
Tag::query()
|
||||
|
||||
Reference in New Issue
Block a user