You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xshop/app/Http/Resources/PostResource.php

39 lines
941 B
PHTML

<?php
namespace App\Http\Resources;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class PostResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
/**
* @var $this Post
*/
return [
'id' => $this->id,
'slug' => $this->slug,
'subtitle' => $this->subtitle,
'body' => $this->body,
'group' => $this->load('groups'),
'author' => $this->load('author'),
'view' => $this->view,
'is_pinned' => $this->is_pinned,
'hash' => $this->hash,
'like' => $this->like,
'dislike' => $this->dislike,
'icon' => $this->icon,
'created_at' => $this->created_at,
];
}
}