<?php
namespace App\Model;


class Presentacion extends GenericObject
{
    static $table_name = 'artprecan';

    public function cargar($data){
        $this->pca_codart = $data->articulo->id;
        $this->pca_precio = $data->precio;
        $this->pca_canti = $data->cantidad;
        $this->pca_item = $data->item;
        $this->pca_codaps = $data->codigo;
    }

    public static function toJSON($result)
    {
        if ($result === null) return $result;
        $temp = array();
        foreach($result as $item){
            try {
                $object = array(
                    "articulo_id" => $item->pca_codart,
                    "precio" => $item->pca_precio,
                    "cantidad" => $item->pca_canti,
                    "item" => $item->pca_item,
                    "codigo" => $item->pca_codaps
                );
                $temp[] = $object;
            } catch (\Throwable $th) {
            }
        }
        return json_encode($temp);
    }

}