mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
fix eager
This commit is contained in:
@@ -42,6 +42,10 @@ class EventTable extends Component
|
|||||||
'coords' => [$event->venue->city->latitude, $event->venue->city->longitude],
|
'coords' => [$event->venue->city->latitude, $event->venue->city->longitude],
|
||||||
]),
|
]),
|
||||||
'events' => CourseEvent::query()
|
'events' => CourseEvent::query()
|
||||||
|
->with([
|
||||||
|
'course',
|
||||||
|
'venue.city.country',
|
||||||
|
])
|
||||||
->where('from', '>=', now())
|
->where('from', '>=', now())
|
||||||
->get()
|
->get()
|
||||||
->map(fn($event) => [
|
->map(fn($event) => [
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class BookCaseTable extends DataTableComponent
|
|||||||
'date' => null,
|
'date' => null,
|
||||||
'comment' => '',
|
'comment' => '',
|
||||||
];
|
];
|
||||||
protected $model = BookCase::class;
|
|
||||||
public string $tableName = 'bookcases';
|
public string $tableName = 'bookcases';
|
||||||
|
protected $model = BookCase::class;
|
||||||
|
|
||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
@@ -121,6 +121,9 @@ class BookCaseTable extends DataTableComponent
|
|||||||
public function builder(): Builder
|
public function builder(): Builder
|
||||||
{
|
{
|
||||||
return BookCase::query()
|
return BookCase::query()
|
||||||
|
->with([
|
||||||
|
'orangePills',
|
||||||
|
])
|
||||||
->withCount([
|
->withCount([
|
||||||
'orangePills',
|
'orangePills',
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
|
|||||||
class CourseTable extends DataTableComponent
|
class CourseTable extends DataTableComponent
|
||||||
{
|
{
|
||||||
public string $country;
|
public string $country;
|
||||||
|
|
||||||
protected $model = Course::class;
|
|
||||||
public string $tableName = 'courses';
|
public string $tableName = 'courses';
|
||||||
|
protected $model = Course::class;
|
||||||
|
|
||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
@@ -89,6 +88,10 @@ class CourseTable extends DataTableComponent
|
|||||||
public function builder(): Builder
|
public function builder(): Builder
|
||||||
{
|
{
|
||||||
return Course::query()
|
return Course::query()
|
||||||
|
->with([
|
||||||
|
'lecturer',
|
||||||
|
'tags',
|
||||||
|
])
|
||||||
->withCount([
|
->withCount([
|
||||||
'courseEvents',
|
'courseEvents',
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ class EventTable extends DataTableComponent
|
|||||||
public string $country;
|
public string $country;
|
||||||
public bool $viewingModal = false;
|
public bool $viewingModal = false;
|
||||||
public $currentModal;
|
public $currentModal;
|
||||||
protected $model = CourseEvent::class;
|
|
||||||
public string $tableName = 'events';
|
public string $tableName = 'events';
|
||||||
|
protected $model = CourseEvent::class;
|
||||||
|
|
||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
@@ -26,7 +26,7 @@ class EventTable extends DataTableComponent
|
|||||||
->setPrimaryKey('id')
|
->setPrimaryKey('id')
|
||||||
->setDefaultSort('from', 'asc')
|
->setDefaultSort('from', 'asc')
|
||||||
->setAdditionalSelects([
|
->setAdditionalSelects([
|
||||||
'id',
|
'course_events.id',
|
||||||
'course_id',
|
'course_id',
|
||||||
'venue_id',
|
'venue_id',
|
||||||
])
|
])
|
||||||
@@ -165,8 +165,9 @@ class EventTable extends DataTableComponent
|
|||||||
public function builder(): Builder
|
public function builder(): Builder
|
||||||
{
|
{
|
||||||
return CourseEvent::query()
|
return CourseEvent::query()
|
||||||
->withCount([
|
->with([
|
||||||
'registrations',
|
'course.lecturer',
|
||||||
|
'course.categories',
|
||||||
])
|
])
|
||||||
->where('from', '>=', now())
|
->where('from', '>=', now())
|
||||||
->whereHas('venue.city.country',
|
->whereHas('venue.city.country',
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use App\Models\Tag;
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Column;
|
use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;
|
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
|
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
|
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;
|
||||||
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
|
use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
|
||||||
@@ -18,8 +17,8 @@ use Spatie\LaravelOptions\Options;
|
|||||||
class LibraryItemTable extends DataTableComponent
|
class LibraryItemTable extends DataTableComponent
|
||||||
{
|
{
|
||||||
public string $currentTab;
|
public string $currentTab;
|
||||||
protected $model = LibraryItem::class;
|
|
||||||
public string $tableName = 'library_items';
|
public string $tableName = 'library_items';
|
||||||
|
protected $model = LibraryItem::class;
|
||||||
|
|
||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
@@ -159,6 +158,10 @@ class LibraryItemTable extends DataTableComponent
|
|||||||
->getName() !== 'library.table.lecturer';
|
->getName() !== 'library.table.lecturer';
|
||||||
|
|
||||||
return LibraryItem::query()
|
return LibraryItem::query()
|
||||||
|
->with([
|
||||||
|
'lecturer',
|
||||||
|
'tags',
|
||||||
|
])
|
||||||
->whereHas('libraries', fn($query) => $query->where('libraries.is_public', $shouldBePublic))
|
->whereHas('libraries', fn($query) => $query->where('libraries.is_public', $shouldBePublic))
|
||||||
->when($this->currentTab !== '*', fn($query) => $query->whereHas('libraries',
|
->when($this->currentTab !== '*', fn($query) => $query->whereHas('libraries',
|
||||||
fn($query) => $query->where('libraries.name', $this->currentTab)))
|
fn($query) => $query->where('libraries.name', $this->currentTab)))
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
|
|||||||
class MeetupTable extends DataTableComponent
|
class MeetupTable extends DataTableComponent
|
||||||
{
|
{
|
||||||
public ?string $country = null;
|
public ?string $country = null;
|
||||||
|
|
||||||
protected $model = Meetup::class;
|
|
||||||
public string $tableName = 'meetups';
|
public string $tableName = 'meetups';
|
||||||
|
protected $model = Meetup::class;
|
||||||
|
|
||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
@@ -72,6 +71,11 @@ class MeetupTable extends DataTableComponent
|
|||||||
public function builder(): Builder
|
public function builder(): Builder
|
||||||
{
|
{
|
||||||
return Meetup::query()
|
return Meetup::query()
|
||||||
|
->with([
|
||||||
|
'users',
|
||||||
|
'city.country',
|
||||||
|
'meetupEvents',
|
||||||
|
])
|
||||||
->when($this->country, fn($query, $country) => $query->whereHas('city.country',
|
->when($this->country, fn($query, $country) => $query->whereHas('city.country',
|
||||||
fn($query) => $query->where('code', $this->country)))
|
fn($query) => $query->where('code', $this->country)))
|
||||||
->withCount([
|
->withCount([
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Providers;
|
|||||||
use App\Models\Episode;
|
use App\Models\Episode;
|
||||||
use App\Observers\EpisodeObserver;
|
use App\Observers\EpisodeObserver;
|
||||||
use App\Support\Carbon;
|
use App\Support\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\Date;
|
use Illuminate\Support\Facades\Date;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -29,6 +30,8 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
|
Model::preventLazyLoading();
|
||||||
|
|
||||||
Stringable::macro('initials', function () {
|
Stringable::macro('initials', function () {
|
||||||
$words = preg_split("/\s+/", $this);
|
$words = preg_split("/\s+/", $this);
|
||||||
$initials = "";
|
$initials = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user