12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace App\Http\Resources\API;
- use Illuminate\Http\Request;
- class BimCombineResource extends BaseResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- $deletedIds = $request->input('deleteIds', []);
- $newData = $this->data;
- foreach ($newData as &$value) {
- if (isset($value['bim_file_id']) && in_array($value['bim_file_id'], $deletedIds)) {
- $value['deleted'] = true;
- }
- }
- $data = [
- 'id' => $this->id,
- 'name' => $this->name,
- 'data' => $newData,
- // 'library' => new LibraryResource($this->library),
- 'created_at' => (string) $this->created_at,
- ];
- return $data;
- }
- }
|