app/Http/Resources/PostResource.php
/**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
Transform the resource into an array.
Transform the resource into an array .
public function toArray($request)
    {
        return [
            'id' => $this->id,
            'title' => $this->title,
            'body' => $this->body,
            'image' => $this->image,
            'blogger' => $this->user->name,
            'date' => $this->created_at->diffForHumans(),
        ];
    }
public function toArray ( $ request ) { return [ 'id' => $ this -> id , 'title' => $ this -> title , 'body' => $ this -> body , 'image' => $ this -> image , 'blogger' => $ this -> user -> name , 'date' => $ this -> created_at -> diffForHumans ( ) , ] ; }
Transform the resource into an array.
Transform the resource into an array .