31 lines
		
	
	
	
		
			927 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			927 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Http\Resources;
 | 
						|
 | 
						|
use Illuminate\Http\Resources\Json\JsonResource;
 | 
						|
 | 
						|
class ProductoResource extends JsonResource
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Transform the resource into an array.
 | 
						|
     *
 | 
						|
     * @param  \Illuminate\Http\Request  $request
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function toArray($request)
 | 
						|
    {
 | 
						|
        return [
 | 
						|
            'id' => $this->id,
 | 
						|
            'nombre' => $this->nombre,
 | 
						|
            'precio' => $this->precio,
 | 
						|
            'categoria' => $this->categoria,
 | 
						|
            'proveedor' => optional($this->proveedor)->nombre,
 | 
						|
            'economia_solidaria' => optional($this->proveedor)->economia_solidaria,
 | 
						|
            'nacional' => optional($this->proveedor)->nacional,
 | 
						|
            'imagen' => optional($this->poster)->url(),
 | 
						|
            'descripcion' => $this->descripcion,
 | 
						|
            'apto_veganxs' => $this->apto_veganxs,
 | 
						|
            'apto_celiacxs'  => $this->apto_celiacxs
 | 
						|
        ];
 | 
						|
    }
 | 
						|
}
 |