app/Http/Resources/ForumFullResource.php
/**
     * Transform the resource into an array.
     *
     * @param Request $request
     * @return array
     */
Transform the resource into an array.
@param Request $request
@return array
Transform the resource into an array . @param Request $request @return array
public function toArray($request)
    {
        $flags = $this->flags;
        $comments = $this->additional['comments'];
        return [
            'id' => $this->id,
            'title' => $this->title,
            'slug' => $this->slug,
            'type' => $this->type,
            'status' => $this->status,
            'body' => markdownToHtml(strip_tags($this->body)),
            'createdAt' => formatDate($this->created_at),
            'updatedAt' => formatDate($this->updated_at),
            'likes' => $this->flagsCountByType($flags, 'good'),
            'dislikes' => $this->flagsCountByType($flags, 'bad'),
            'user' => new UserResource($this->user),
            'destinations' => DestinationResource::collection($this->destinations),
            'topics' => TopicResource::collection($this->topics),
            'comments' => CommentResource::collection($comments)
        ];
    }
public function toArray ( $ request ) { $ flags = $ this -> flags ; $ comments = $ this -> additional [ 'comments' ] ; return [ 'id' => $ this -> id , 'title' => $ this -> title , 'slug' => $ this -> slug , 'type' => $ this -> type , 'status' => $ this -> status , 'body' => markdownToHtml ( strip_tags ( $ this -> body ) ) , 'createdAt' => formatDate ( $ this -> created_at ) , 'updatedAt' => formatDate ( $ this -> updated_at ) , 'likes' => $ this -> flagsCountByType ( $ flags , 'good' ) , 'dislikes' => $ this -> flagsCountByType ( $ flags , 'bad' ) , 'user' => new UserResource ( $ this -> user ) , 'destinations' => DestinationResource :: collection ( $ this -> destinations ) , 'topics' => TopicResource :: collection ( $ this -> topics ) , 'comments' => CommentResource :: collection ( $ comments ) ] ; }
Transform the resource into an array.
Transform the resource into an array .