Files
alrahma_sunday_school_api/app/Http/Resources/ClassProgress/ClassProgressAttachmentResource.php
T
2026-04-23 00:04:35 -04:00

23 lines
675 B
PHP

<?php
namespace App\Http\Resources\ClassProgress;
use App\Services\ApplicationUrlService;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ClassProgressAttachmentResource extends JsonResource
{
public function toArray(Request $request): array
{
$id = $this['id'] ?? $this->id ?? null;
return [
'id' => $id ? (int) $id : null,
'name' => $this['name'] ?? $this->original_name ?? null,
'file_path' => $this['file_path'] ?? $this->file_path ?? null,
'download_url' => $id ? app(ApplicationUrlService::class)->forClassProgressAttachment($id) : null,
];
}
}