12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
46
app/Http/Resources/PressReleaseImageResource.php
Normal file
46
app/Http/Resources/PressReleaseImageResource.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class PressReleaseImageResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$variants = is_array($this->variants) ? $this->variants : [];
|
||||
$variantUrls = [];
|
||||
|
||||
foreach ($variants as $key => $relativePath) {
|
||||
if (is_string($relativePath) && filled($relativePath)) {
|
||||
$variantUrls[$key] = asset('storage/'.ltrim($relativePath, '/'));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'press_release_id' => $this->press_release_id,
|
||||
'url' => $this->url(),
|
||||
'urls' => array_merge(['original' => $this->url()], $variantUrls),
|
||||
'variants' => $variants,
|
||||
'disk' => $this->disk,
|
||||
'path' => $this->path,
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'copyright' => $this->copyright,
|
||||
'is_preview' => $this->is_preview,
|
||||
'sort_order' => $this->sort_order,
|
||||
'width' => $this->width,
|
||||
'height' => $this->height,
|
||||
'mime' => $this->mime,
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue