app/Http/Resources/ImageResource.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)
    {
        $backgroundImage = $this->backgroundImage;
        return [
            'id' => $this->id,
            'title' => $this->title,
            'user' => new UserResource($this->whenLoaded('user')),
            'createdAt' => formatDate($this->created_at),
            'urlSmall' => env('IMAGE_PATH') . '/content/small/' . $backgroundImage->filename,
            'urlLarge' => env('IMAGE_PATH') . '/content/large/' . $backgroundImage->filename
        ];
    }
public function toArray ( $ request ) { $ backgroundImage = $ this -> backgroundImage ; return [ 'id' => $ this -> id , 'title' => $ this -> title , 'user' => new UserResource ( $ this -> whenLoaded ( 'user' ) ) , 'createdAt' => formatDate ( $ this -> created_at ) , 'urlSmall' => env ( 'IMAGE_PATH' ) . '/content/small/' . $ backgroundImage -> filename , 'urlLarge' => env ( 'IMAGE_PATH' ) . '/content/large/' . $ backgroundImage -> filename ] ; }
Transform the resource into an array.
Transform the resource into an array .