public function cast($model)
    {
        if ($model instanceof Collection) {
            return $model->map([$this, 'cast'])->toArray();
        }

        if (empty($model)) {
            return;
        }

        $transformed = [];

        foreach ($this->castRules() as $old => $desired) {
            $this->resolveCast($old, $desired, $model, $transformed);
        }

        return $transformed;
    }
public function cast($model)
    {
        if ($model instanceof Collection) {
            return $model->map([$this, 'cast'])->toArray();
        }

        if (empty($model)) {
            return;
        }

        $transformed = [];

        foreach ($this->castRules() as $old => $desired) {
            $this->resolveCast($old, $desired, $model, $transformed);
        }

        return $transformed;
    }
public function cast ( $ model ) { if ( $ model instanceof Collection ) { return $ model -> map ( [ $ this , 'cast' ] ) -> toArray ( ) ; } if ( empty ( $ model ) ) { return ; } $ transformed = [ ] ; foreach ( $ this -> castRules ( ) as $ old => $ desired ) { $ this -> resolveCast ( $ old , $ desired , $ model , $ transformed ) ; } return $ transformed ; }
Casts collection fields.

@param  mixed  $model
@return array
Casts collection fields .