mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
tabs added
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Http\Livewire\Frontend;
|
||||
|
||||
use App\Models\Country;
|
||||
use Livewire\Component;
|
||||
|
||||
class SearchCourse extends Component
|
||||
{
|
||||
public Country $country;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.frontend.search-course');
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Http\Livewire\Frontend;
|
||||
|
||||
use App\Models\Country;
|
||||
use Livewire\Component;
|
||||
|
||||
class SearchEvent extends Component
|
||||
{
|
||||
public Country $country;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.frontend.search-event');
|
||||
|
||||
@@ -9,6 +9,8 @@ use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||
|
||||
class CourseTable extends DataTableComponent
|
||||
{
|
||||
public string $country;
|
||||
|
||||
protected $model = Course::class;
|
||||
|
||||
public function configure(): void
|
||||
@@ -19,22 +21,29 @@ class CourseTable extends DataTableComponent
|
||||
public function columns(): array
|
||||
{
|
||||
return [
|
||||
Column::make("Id", "id")
|
||||
->sortable(),
|
||||
Column::make("Lecturer id", "lecturer_id")
|
||||
Column::make("Dozent", "lecturer.name")
|
||||
->sortable(),
|
||||
Column::make("Name", "name")
|
||||
->sortable(),
|
||||
Column::make("Created at", "created_at")
|
||||
Column::make("Termine")
|
||||
->label(
|
||||
fn($row, Column $column) => '<strong>'.$row->events->count().'</strong>'
|
||||
)
|
||||
->html()
|
||||
->sortable(),
|
||||
Column::make("Updated at", "updated_at")
|
||||
Column::make("Erstellt am", "created_at")
|
||||
->sortable(),
|
||||
Column::make('')
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.courses.action')->withRow($row)
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public function builder(): Builder
|
||||
{
|
||||
return Course::query()
|
||||
->whereHas('country', fn($query) => $query->where('code', $this->country));
|
||||
->whereHas('events.venue.city.country',
|
||||
fn($query) => $query->where('countries.code', $this->country));
|
||||
}
|
||||
}
|
||||
|
||||
63
app/Http/Livewire/Tables/EventTable.php
Normal file
63
app/Http/Livewire/Tables/EventTable.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Tables;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||
|
||||
class EventTable extends DataTableComponent
|
||||
{
|
||||
public string $country;
|
||||
|
||||
protected $model = Event::class;
|
||||
|
||||
public function configure(): void
|
||||
{
|
||||
$this
|
||||
->setPrimaryKey('id')
|
||||
->setAdditionalSelects([
|
||||
'course_id',
|
||||
'venue_id',
|
||||
]);
|
||||
}
|
||||
|
||||
public function columns(): array
|
||||
{
|
||||
return [
|
||||
Column::make("Stadt", "venue.city.name")
|
||||
->sortable(),
|
||||
Column::make("Veranstaltungs-Ort", "venue.name")
|
||||
->sortable(),
|
||||
Column::make("Dozent", "course.lecturer.name")
|
||||
->sortable(),
|
||||
Column::make("Kurs", "course.name")
|
||||
->sortable(),
|
||||
Column::make("Erstellt am", "created_at")
|
||||
->sortable(),
|
||||
Column::make("Zuletzt geändert", "updated_at")
|
||||
->sortable(),
|
||||
Column::make("Teilnehmer")
|
||||
->label(
|
||||
fn($row, Column $column) => '<strong>'.$row->registrations->count().'</strong>'
|
||||
)
|
||||
->html()
|
||||
->sortable(),
|
||||
Column::make('')
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.events.action')->withRow($row)
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public function builder(): Builder
|
||||
{
|
||||
return Event::query()
|
||||
->withCount([
|
||||
'registrations',
|
||||
])
|
||||
->whereHas('venue.city.country',
|
||||
fn($query) => $query->where('countries.code', $this->country));
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,10 @@ class VenueTable extends DataTableComponent
|
||||
->sortable(),
|
||||
Column::make("Street", "street")
|
||||
->sortable(),
|
||||
Column::make('')
|
||||
->label(
|
||||
fn($row, Column $column) => view('columns.venues.action')->withRow($row)
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -35,4 +35,9 @@ class Course extends Model
|
||||
{
|
||||
return $this->belongsTo(Lecturer::class);
|
||||
}
|
||||
|
||||
public function events(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,9 @@ class Event extends Model
|
||||
{
|
||||
return $this->belongsTo(Venue::class);
|
||||
}
|
||||
|
||||
public function registrations(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Registration::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user