<?php
namespace App\Model;


class Deposito extends GenericObject
{
    static $table_name = 'deposito';

    static $primary_key = 'dep_codigo';

    public function cargar($data){
        $this->dep_codigo = $data->id;
        $this->dep_descri = $data->descripcion;
    }

    public static function toJSON($result)
    {
        if ($result === null) return $result;
        $temp = array();
        if(!isset($result->dep_codigo)){
            foreach($result as $item){
                $object = array(
                    "id" => $item->dep_codigo,
                    "descripcion" => $item->dep_descri
                );
                $temp[] = $object;
            }
        }else{
            $temp = array(
                "id" => $result->dep_codigo,
                "descripcion" => $result->dep_descri
            );
        }
        return json_encode($temp);
    }

}