app/Http/Resources/CommentResource.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): array
    {
        $flags = $this->flags;
        $createdAt = $this->created_at;
        return [
            'id' => $this->id,
            'contentId' => $this->content_id,
            'body' => markdownToHtml(strip_tags($this->body)),
            'status' => $this->status,
            'createdAt' => formatDate($this->created_at),
            'likes' => $this->flagsCountByType($flags, 'good'),
            'dislikes' => $this->flagsCountByType($flags, 'bad'),
            'user' => new UserResource($this->user),
            'hasTimeToEdit' => Carbon::now()->subDay() < $createdAt 
        ];
    }
public function toArray ( $ request ) : array { $ flags = $ this -> flags ; $ createdAt = $ this -> created_at ; return [ 'id' => $ this -> id , 'contentId' => $ this -> content_id , 'body' => markdownToHtml ( strip_tags ( $ this -> body ) ) , 'status' => $ this -> status , 'createdAt' => formatDate ( $ this -> created_at ) , 'likes' => $ this -> flagsCountByType ( $ flags , 'good' ) , 'dislikes' => $ this -> flagsCountByType ( $ flags , 'bad' ) , 'user' => new UserResource ( $ this -> user ) , 'hasTimeToEdit' => Carbon :: now ( ) -> subDay ( ) < $ createdAt ] ; }
Transform the resource into an array.
Transform the resource into an array .
//can change within 24h