/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Http/Fixtures/PostResourceWithOptionalRelationshipAggregates.php
17 строк
584 B
AkrAm
[10.x] Add `whenAggregated` method to `ConditionallyLoadsAttributes` trait (#47417)
17 июн 2023, 00:27
Не верифицирован
17 июн 2023, 00:27
f42ae50
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Http\Fixtures; class PostResourceWithOptionalRelationshipAggregates extends PostResource { public function toArray($request) { return [ 'id' => $this->id, 'title' => $this->title, 'average_rating' => $this->whenAggregated('comments', 'rating', 'avg'), 'minimum_rating' => $this->whenAggregated('comments', 'rating', 'min'), 'maximum_rating' => $this->whenAggregated('comments', 'rating', 'max', fn ($avg) => "$avg ratings", 'Default Value'), ]; } }