BimCombineResource.php 853 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Resources\API;
  3. use Illuminate\Http\Request;
  4. class BimCombineResource extends BaseResource
  5. {
  6. /**
  7. * Transform the resource into an array.
  8. *
  9. * @return array<string, mixed>
  10. */
  11. public function toArray(Request $request): array
  12. {
  13. $deletedIds = $request->input('deleteIds', []);
  14. $newData = $this->data;
  15. foreach ($newData as &$value) {
  16. if (isset($value['bim_file_id']) && in_array($value['bim_file_id'], $deletedIds)) {
  17. $value['deleted'] = true;
  18. }
  19. }
  20. $data = [
  21. 'id' => $this->id,
  22. 'name' => $this->name,
  23. 'data' => $newData,
  24. // 'library' => new LibraryResource($this->library),
  25. 'created_at' => (string) $this->created_at,
  26. ];
  27. return $data;
  28. }
  29. }