hhm_backend_03_2023/plugins/rainlab/blog/classes/PostResource.php

39 lines
1.5 KiB
PHP
Raw Normal View History

2023-03-08 19:44:42 +00:00
<?php
namespace RainLab\Blog\Classes;
use Illuminate\Http\Resources\Json\JsonResource;
use Config;
class PostResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$locale = $request->get('locale');
$path = Config::get('app.url').Config::get('cms.storage.media.path');
return [
'id' => $this->id,
'title' => $this->getAttributeTranslated('title', $locale),
'slug' => $this->getAttributeTranslated('slug', $locale),
'excerpt' => $this->getAttributeTranslated('excerpt', $locale),
'published_at' => $this->published_at->format('d.m.Y'),
'type' => $this->type,
'awtor' => $this->getAttributeTranslated('awtor', $locale),
'featured_images' => ImageResource::collection($this->featured_images),
'video' => $path.$this->video,
2023-03-08 20:39:07 +00:00
//'content_html' => $this->getAttributeTranslated('content_html', $locale),
2023-03-08 19:44:42 +00:00
'categories' => CategoryResource::collection($this->categories),
2023-03-08 20:39:07 +00:00
//'powerseo_title' => $this->getAttributeTranslated('powerseo_title', $locale),
//'powerseo_description' => $this->getAttributeTranslated('powerseo_description', $locale),
//'powerseo_keywords' => $this->getAttributeTranslated('powerseo_keywords', $locale),
2023-03-08 19:44:42 +00:00
];
}
}