app/Http/Resources/DestinationResource.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)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'slug' => $this->slug,
            'parentDestination' => new DestinationResource($this->whenLoaded('parent'))
        ];
    }
public function toArray ( $ request ) { return [ 'id' => $ this -> id , 'name' => $ this -> name , 'slug' => $ this -> slug , 'parentDestination' => new DestinationResource ( $ this -> whenLoaded ( 'parent' ) ) ] ; }
Transform the resource into an array.
Transform the resource into an array .