CompanyResource.php 705 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Created by IntelliJ IDEA.
  4. * User: kelyliang
  5. * Date: 2024/3/20
  6. * Time: 下午 02:43
  7. */
  8. namespace App\Http\Resources\API;
  9. use App\Models\Company;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Http\Resources\Json\JsonResource;
  12. class CompanyResource extends JsonResource
  13. {
  14. public function toArray(Request $request): array
  15. {
  16. return[
  17. 'id' => $this->id,
  18. 'name' => $this->name,
  19. 'email' => $this->email,
  20. 'review_status' => $this->review_status,
  21. 'exp_date' => $this->exp_date,
  22. 'display_id' => $this->display_id,
  23. 'parent' => $this->parent_id ? new CompanyResource($this->parentCompany) : 0,
  24. ];
  25. }
  26. }