![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ledger.corals.io/Corals/modules/CMS/Transformers/ |
<?php namespace Corals\Modules\CMS\Transformers; use Corals\Foundation\Transformers\BaseTransformer; use Corals\Modules\CMS\Models\Post; class PostTransformer extends BaseTransformer { public function __construct($extras = []) { $this->resource_url = config('cms.models.post.resource_url'); parent::__construct($extras); } /** * @param Post $post * @return array * @throws \Throwable */ public function transform(Post $post) { $show_url = url($this->resource_url . '/' . $post->hashed_id); $transformedArray = [ 'id' => $post->id, 'checkbox' => $this->generateCheckboxElement($post), 'title' => '<a href="' . $show_url . '" target="_blank">' . \Str::limit($post->title, 50) . '</a>', 'slug' => ($post->internal ? 'cms/' : '') . $post->slug, 'published' => $post->published ? '<i class="fa fa-check text-success"></i>' : '-', 'published_at' => $post->published ? format_date($post->published_at) : '-', 'categories' => formatArrayAsLabels($post->categories->pluck('name'), 'success', '<i class="fa fa-folder-open"></i>'), 'private' => $post->private ? '<i class="fa fa-check text-success"></i>' : '-', 'internal' => $post->internal ? '<i class="fa fa-check text-success"></i>' : '-', 'created_at' => format_date($post->created_at), 'updated_at' => format_date($post->updated_at), 'action' => $this->actions($post) ]; return parent::transformResponse($transformedArray); } }