%PDF- %PDF-
Direktori : /var/www/html/news/app/Transformers/ |
Current File : /var/www/html/news/app/Transformers/CommentTransformer.php |
<?php namespace App\Transformers; use App\Models\Comment; class CommentTransformer extends BaseTransformer { protected $availableIncludes = [ 'user' ]; public function transform(Comment $comment) { $data = $this->transformColumns($comment); $data['is_appropriate'] = $comment->isAppropriate(); return $data; } public function includeUser(Comment $comment) { if (!empty($comment->user)) { return $this->item($comment->user, new UserTransformer, 'user'); } } protected function getTransformableColumns() { return [ 'id' => 'id', 'content' => 'content', 'is_approved' => 'is_approved', 'user_id' => 'user_id', 'article_id' => 'article_id', 'created_at' => 'created_at', 'updated_at' => 'updated_at' ]; } }