/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Http/Fixtures/PostResourceWithOptionalHasAttributes.php
24 строки
771 B
Michael Nabil
[9.x] Add `whenHas` to JsonResource (#45376)
24 дек 2022, 00:42
Не верифицирован
24 дек 2022, 00:42
b83a1ce
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Http\Fixtures; use Illuminate\Http\Resources\Json\JsonResource; class PostResourceWithOptionalHasAttributes extends JsonResource { public function toArray($request) { return [ 'id' => $this->id, 'first' => $this->whenHas('is_published'), 'second' => $this->whenHas('is_published', 'override value'), 'third' => $this->whenHas('is_published', function () { return 'override value'; }), 'fourth' => $this->whenHas('is_published', $this->is_published, 'default'), 'fifth' => $this->whenHas('is_published', $this->is_published, function () { return 'default'; }), ]; } }