N+1
This commit is contained in:
parent
ee14ce3aef
commit
4a87232dae
@ -159,10 +159,12 @@ public function setReportDate(string $from, ?string $to = null): self
|
||||
protected function getStudiesQuery(): Builder
|
||||
{
|
||||
if ($this->archived === null) {
|
||||
return Study::active();
|
||||
$q = Study::active();
|
||||
} else {
|
||||
$q = Study::query();
|
||||
}
|
||||
|
||||
return Study::query();
|
||||
return $q->with(['readingPhysician', 'assignedPhysician']);
|
||||
}
|
||||
|
||||
protected function applySort(Builder $query): Builder
|
||||
|
@ -103,6 +103,11 @@ public function readingPhysician(): BelongsTo
|
||||
return $this->belongsTo(User::class, 'reporting_physician_id');
|
||||
}
|
||||
|
||||
public function assignedPhysician(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_physician_id');
|
||||
}
|
||||
|
||||
public function getReportStatusLedAttribute(): string
|
||||
{
|
||||
$color = match ($this->report_status) {
|
||||
@ -230,6 +235,7 @@ public function toArray(): array
|
||||
return array_merge(parent::toArray(), [
|
||||
'disk_size_human' => human_filesize($this->disk_size),
|
||||
'reader_name' => $this->readingPhysician?->display_name,
|
||||
'assigned_physician_name' => $this->assignedPhysician?->display_name,
|
||||
'reader_photo' => $this->readingPhysician?->profile_photo_url,
|
||||
'report_status_led' => $this->getReportStatusLedAttribute(),
|
||||
'priority_icon' => $this->getPriorityIcon(),
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@ -21,6 +22,7 @@ public function register(): void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->configureModels();
|
||||
Paginator::useBootstrapFive();
|
||||
Vite::useStyleTagAttributes(function (?string $src, string $url, ?array $chunk, ?array $manifest) {
|
||||
if ($src !== null) {
|
||||
@ -33,4 +35,9 @@ public function boot(): void
|
||||
return [];
|
||||
});
|
||||
}
|
||||
|
||||
private function configureModels(): void
|
||||
{
|
||||
Model::shouldBeStrict(! $this->app->isProduction());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user