<?php

namespace App\Http\Resources;
use App\Http\Resources\ModelResource;
use App\Http\Resources\CategoryResource;
use App\Http\Resources\ProductResource;

use Illuminate\Http\Resources\Json\JsonResource;
use App\ModelDescription;
use App\Language;
use App\Models;
use App\Category;
use Illuminate\Http\Request;



class ProductResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        
        //return parent::toArray($request);
        $mainmodel = $this->whenLoaded('mainmodel');
        
        return [
            'id' => $this->id,
            'name' =>$this->descriptions(currentLanguage()->id)['name'],
            'description' =>$this->descriptions(currentLanguage()->id)['description'],
            //'mainmodel'=>new CategoryResource($mainmodel),
            
      ];
    }
}
