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()
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -17,7 +16,6 @@ use Spatie\Tags\HasTags;
|
||||
|
||||
class LibraryItem extends Model implements HasMedia, Sortable
|
||||
{
|
||||
use HasFactory;
|
||||
use InteractsWithMedia;
|
||||
use HasTags;
|
||||
use SortableTrait;
|
||||
|
||||
@@ -88,6 +88,12 @@ class Lecturer extends Resource
|
||||
Text::make('Name')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Markdown::make(__('Subtitle'), 'subtitle')
|
||||
->help(__('This is the subtitle on the landing page.')),
|
||||
|
||||
Markdown::make(__('Intro'), 'intro')
|
||||
->help(__('This is the introduction text that is shown on the landing page.')),
|
||||
|
||||
Text::make('Slug')
|
||||
->rules('required', 'string', 'unique:lecturers,slug')
|
||||
->exceptOnForms(),
|
||||
@@ -108,7 +114,8 @@ class Lecturer extends Resource
|
||||
return $request->user()
|
||||
->hasRole('super-admin');
|
||||
})
|
||||
->searchable()->withSubtitles(),
|
||||
->searchable()
|
||||
->withSubtitles(),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user