You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
664 B

2 years ago
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. class UserResource extends JsonResource
  5. {
  6. /**
  7. * Transform the resource into an array.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
  11. */
  12. public function toArray($request)
  13. {
  14. return [
  15. 'id' => $this->id,
  16. 'name' => $this->name,
  17. 'status' => $this->status,
  18. 'dirties' => $this->when($this->resource->hasDirty(), function () {
  19. return $this->resource->getOldDirty();
  20. })
  21. ];
  22. }
  23. }