12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace App\Http\Resources\API;
- use App\Models\Enums\BimFileConvertStatus;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- use Illuminate\Support\Facades\Storage;
- class FileDownloadResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- $data = [
- 'id' => $this->id,
- 'title' => $this->title,
- 'download_url' => Storage::url($this->pathname),
- 'extension' => $this->extension,
- 'size' => $this->size,
- 'version' => $this->version,
- ];
- if ($this->is_bim == 1 && $this->bimFile && $this->bimFile->convert_status == BimFileConvertStatus::DONE->value) {
- $data['model_preview'] = true;
- }
- return $data;
- }
- }
|