update deploy
This commit is contained in:
36
app/Http/Resources/AnnouncementResource.php
Normal file
36
app/Http/Resources/AnnouncementResource.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Announcement;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin Announcement
|
||||
*/
|
||||
class AnnouncementResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'slug' => $this->slug,
|
||||
'title' => $this->title,
|
||||
'category' => $this->category?->value,
|
||||
'excerpt' => $this->excerpt,
|
||||
'content' => $this->content,
|
||||
'image' => $this->image,
|
||||
'is_featured' => $this->is_featured,
|
||||
'meta_title' => $this->meta_title,
|
||||
'meta_description' => $this->meta_description,
|
||||
'published_at' => $this->published_at?->toISOString(),
|
||||
'comments' => CommentResource::collection($this->whenLoaded('comments')),
|
||||
'created_at' => $this->created_at?->toISOString(),
|
||||
'updated_at' => $this->updated_at?->toISOString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user