Files
water_new/modules/Cms/Http/Resources/ArticleBaseResource.php
2023-03-08 09:16:04 +08:00

29 lines
963 B
PHP

<?php
namespace Modules\Cms\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ArticleBaseResource extends JsonResource
{
public function toArray($request): array
{
return [
'article_id' => $this->id,
'title' => $this->title,
// 'sub_title' => $this->sub_title,
'description' => $this->description,
// 'slug' => $this->slug,
'categories' => CategoryBaseResource::collection($this->categories),
'tags' => TagResource::collection($this->tags),
'cover' => $this->cover_url,
'pictures' => $this->pictures_url,
'clicks' => $this->clicks,
'favorites' => $this->favorites()->count(),
'subscribes' => $this->subscribers()->count(),
'created_at' => (string) $this->created_at,
];
}
}