/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Http/Fixtures/PostResourceWithOptionalRelationshipExists.php
18 строк
533 B
Kyrian Obikwelu
[11.x] Add `whenExistsLoaded` method to conditionally include relationship existence attribute (#52295)
01 авг 2024, 22:28
Не верифицирован
01 авг 2024, 22:28
edc106e
Код
Авторство
О чём код?
<?php declare(strict_types=1); namespace Illuminate\Tests\Integration\Http\Fixtures; class PostResourceWithOptionalRelationshipExists extends PostResource { public function toArray($request) { return [ 'id' => $this->id, 'has_authors' => $this->whenExistsLoaded('authors'), 'has_favourited_posts' => $this->whenExistsLoaded('favouritedPosts', fn ($exists) => $exists ? 'Yes' : 'No', 'No'), 'comment_exists' => $this->whenExistsLoaded('comments'), ]; } }