mtv\models\Model::to_json PHP Метод

to_json() публичный Метод

Returns an assoc array of this model's data to send over the wire
public to_json ( )
    public function to_json()
    {
        // decide which fields to send over the wire
        if (empty($this->json_fields)) {
            return $this->attributes;
        } else {
            $ret = array();
            foreach ($this->json_fields as $k) {
                $ret[$k] = $this->attributes[$k];
            }
            return $ret;
        }
    }

Usage Example

Пример #1
0
 public function to_json()
 {
     return parent::to_json() + array('sites' => $this->sites()->to_json());
 }