src/Models/ArrayableModel.php
public function toArray()
    {
        $array = $this->fields;

        foreach ($this->appends as $accessor) {
            if (isset($this[$accessor])) {
                $array[$accessor] = $this[$accessor];
            }
        }

        foreach ($this->related as $key => $value) {
            if (is_object($value) && method_exists($value, 'toArray')) {
                $array[$key] = $value->toArray();
            } elseif (is_null($value) || $value === false) {
                $array[$key] = $value;
            }
        }

        if (count($this->getVisible()) > 0) {
            $array = array_intersect_key($array, array_flip($this->getVisible()));
        }

        if (count($this->getHidden()) > 0) {
            $array = array_diff_key($array, array_flip($this->getHidden()));
        }

        return $array;
    }
public function toArray()
    {
        $array = $this->fields;

        foreach ($this->appends as $accessor) {
            if (isset($this[$accessor])) {
                $array[$accessor] = $this[$accessor];
            }
        }

        foreach ($this->related as $key => $value) {
            if (is_object($value) && method_exists($value, 'toArray')) {
                $array[$key] = $value->toArray();
            } elseif (is_null($value) || $value === false) {
                $array[$key] = $value;
            }
        }

        if (count($this->getVisible()) > 0) {
            $array = array_intersect_key($array, array_flip($this->getVisible()));
        }

        if (count($this->getHidden()) > 0) {
            $array = array_diff_key($array, array_flip($this->getHidden()));
        }

        return $array;
    }
public function toArray ( ) { $ array = $ this -> fields ; foreach ( $ this -> appends as $ accessor ) { if ( isset ( $ this [ $ accessor ] ) ) { $ array [ $ accessor ] = $ this [ $ accessor ] ; } } foreach ( $ this -> related as $ key => $ value ) { if ( is_object ( $ value ) && method_exists ( $ value , 'toArray' ) ) { $ array [ $ key ] = $ value -> toArray ( ) ; } elseif ( is_null ( $ value ) || $ value === false ) { $ array [ $ key ] = $ value ; } } if ( count ( $ this -> getVisible ( ) ) > 0 ) { $ array = array_intersect_key ( $ array , array_flip ( $ this -> getVisible ( ) ) ) ; } if ( count ( $ this -> getHidden ( ) ) > 0 ) { $ array = array_diff_key ( $ array , array_flip ( $ this -> getHidden ( ) ) ) ; } return $ array ; }
Cast model to array.

@return array
Cast model to array .