app/Http/Resources/DemoContentResource.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,
            'name' => $this->name,
            'price' => $this->price,
            'production_date' => $this->production_date,
            'main_product_id' => $this->main_product_id,
            'main_product_name' => $this->mainProduct->name,
            'type' => $this->type,
            'status' => $this->status,
        ];
    }
public function toArray ( $ request ) { return [ 'id' => $ this -> id , 'name' => $ this -> name , 'price' => $ this -> price , 'production_date' => $ this -> production_date , 'main_product_id' => $ this -> main_product_id , 'main_product_name' => $ this -> mainProduct -> name , 'type' => $ this -> type , 'status' => $ this -> status , ] ; }
Transform the resource into an array.
Transform the resource into an array .