<?php
namespace App\Model;


class Zona extends GenericObject
{
    static $table_name = 'zona';

    static $primary_key = 'zon_codigo';

    public function cargar($data){
        $this->zon_codigo = $data->id;
        $this->zon_descri = $data->descripcion;
        $this->zon_ruta = $data->ruta;
    }

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

}