Convert the model's attributes to an array.

@inheritdoc
346092
public function attributesToArray()
    {
        // unset date values that are 0, so they don't cause problems with serializeDate()
        foreach ($this->getDates() as $key) {
            if ( ! isset($this->attributes[$key])) continue;

            // 0 should be considered 'unset' aswell
            if (0 === $this->attributes[$key]) {
                $this->attributes[$key] = null;
            }
        }

        return parent::attributesToArray();
    }
382389
public function toArray(): array
	{
		$columns = $this->columns;

		// Removes protected columns from the array

		if(!empty($this->protected))
		{
			$columns = array_diff_key($columns, array_flip($this->protected));
		}

		// Mutate column values if needed

		foreach($columns as $name => $value)
		{
			$value = $this->getColumnValue($name);

			if($value instanceof DateTimeInterface)
			{
				$value = $value->format($this->dateOutputFormat);
			}

			$columns[$name] = $value;
		}

		// Merge in related records

		foreach($this->related as $relation => $related)
		{
			if(in_array($relation, $this->protected))
			{
				continue;
			}

			$columns += [$relation => ($related === false ? $related : $related->toArray())];
		}

		// Returns array representation of the record

		return $columns;
	}
1126326
public function toArray($request)
    {
        return [
            'id'         => (int) $this->id,
            'email'      => $this->email,
            'name'       => $this->name,
            'first_name' => $this->first_name,
            'last_name'  => $this->last_name,
            'roles'      => Role::collection($this->whenLoaded('roles')),
        ];
    }
849168
public function toArray(): array
    {
        $result = $this->orgData;
        foreach ($this->addAttributes as $key => $value) {
            $result[$key] = $value;
        }
        foreach ($this->updateAttributes as $key => $value) {
            $result[$key] = $value;
        }
        foreach ($this->removeAttributes as $key => $value) {
            unset($result[$key]);
        }
        return $result;
    }
639566
public function attributesToArray()
    {
        // If an attribute is a date, we will cast it to a string after converting it
        // to a DateTime / Carbon instance. This is so we will get some consistent
        // formatting while accessing attributes vs. arraying / JSONing a model.
        $attributes = $this->addDateAttributesToArray(
            $attributes = $this->getArrayableAttributes()
        );

        $attributes = $this->addMutatedAttributesToArray(
            $attributes, $mutatedAttributes = $this->getMutatedAttributes()
        );

        // Next we will handle any casts that have been setup for this model and cast
        // the values to their appropriate type. If the attribute has a mutator we
        // will not perform the cast on those attributes to avoid any confusion.
        $attributes = $this->addCastAttributesToArray(
            $attributes, $mutatedAttributes
        );

        // Here we will grab all of the appended, calculated attributes to this model
        // as these attributes are not really in the attributes array, but are run
        // when we need to array or JSON the model for convenience to the coder.
        foreach ($this->getArrayableAppends() as $key) {
            $attributes[$key] = $this->mutateAttributeForArray($key, null);
        }

        return $attributes;
    }
952796
public function toArray(array $attributes = array())
	{
		$data = parent::toArray();

		if(count($attributes) == 0)
			return $data;

		$new = array();

		foreach($attributes as $attribute)
			$new[$attribute] = $data[$attribute];

		return $new;
	}
827004
public function toArray()
    {
        $attributes = [];

        foreach ($this->fillable as $attribute)
        {
            $attributes[$attribute] = $this->getAttributeFromArray($attribute);
        }

        return $attributes;
    }
881933
public function nestedObjectsToArray()
    {
        $attributes = [];

        foreach ($this->getAttributes() as $key => $value) {
            // If the values implements the Arrayable interface we can just call this
            // toArray method on the instances which will convert both objects and
            // collections to their proper array form and we'll set the values.
            if ($value instanceof Arrayable) {
                $attributes[$key] = $value->toArray();
            }
            if (is_array($value)) {
                $attributes[$key] = collect($value)->toArray();
            }
        }

        return $attributes;
    }
348388
public function toArray()
	{
		$output = $this->getAttributes();

		foreach ($this->relationships as $key => $value) {

			if ($value instanceof BaseModel) {
				$value = array($value->getSingularEntityName() => $value->toArray());
			}
			else {
				$value = $value->toArray();
			}

			$output = array_merge($output, $value);
		}

		return $output;
	}
827327
public function toArray()
    {
        $array = array();

        foreach($this->_data as $key=>$value)
            $array[$key] = ($value instanceof PropertyReference) ? $value->value() : $value;

        return $array;
    }
1097777
public function toArray(Model $model)
    {
        // start with the base representation of the model
        if (method_exists($model, 'withoutArrayHook')) {
            $model->withoutArrayHook();
        }
        $result = $model->toArray();

        // apply namespacing to excluded properties
        $namedExc = [];
        foreach ($this->exclude as $k) {
            array_set($namedExc, $k, true);
        }

        // apply namespacing to included properties
        $namedInc = [];
        foreach ($this->include as $k) {
            array_set($namedInc, $k, true);
        }

        // apply namespacing to expanded properties
        $namedExp = [];
        foreach ($this->expand as $k) {
            array_set($namedExp, $k, true);
        }

        // remove excluded properties
        foreach (array_keys($result) as $k) {
            if (isset($namedExc[$k]) && !is_array($namedExc[$k])) {
                unset($result[$k]);
            }
        }

        // add included properties
        foreach (array_keys($namedInc) as $k) {
            if (!isset($result[$k]) && isset($namedInc[$k])) {
                $result[$k] = $model->$k;
                if ($result[$k] instanceof Model) {
                    $subExc = array_value($namedExc, $k);
                    $subInc = array_value($namedInc, $k);
                    $subExp = array_value($namedExp, $k);

                    // convert exclude, include, and expand into dot notation
                    // then take the keys for a flattened dot notation
                    $flatExc = is_array($subExc) ? array_keys(array_dot($subExc)) : [];
                    $flatInc = is_array($subInc) ? array_keys(array_dot($subInc)) : [];
                    $flatExp = is_array($subExp) ? array_keys(array_dot($subExp)) : [];

                    $serializer = new self($this->request);
                    $serializer->setExclude($flatExc)
                        ->setInclude($flatInc)
                        ->setExpand($flatExp);

                    $result[$k] = $serializer->toArray($result[$k]);
                }
            }
        }

        // expand any relational model properties
        $result = $this->expand($model, $result, $namedExc, $namedInc, $namedExp);

        // apply hooks, if available
        if (method_exists($model, 'toArrayHook')) {
            $model->toArrayHook($result, $namedExc, $namedInc, $namedExp);
        }

        // order the properties array by name for consistency
        // since it is constructed in a random order
        ksort($result);

        return $result;
    }
716168
public function toArray()
    {
        return [
            'id' => $this->id,
            'modelType' => $this->model_type,
            'modelId' => $this->model_id,
            'name' => $this->name,
            'price' => $this->price,
            'image' => $this->image,
            'quantity' => $this->quantity,
        ];
    }
78253
public function toArray(): array
    {
        if ( ! count($this->attributes)) {
            return [];
        }

        // make this work recursively
        $array = [];

        foreach ($this->attributes as $key => $attribute) {

            if ($attribute instanceof Arrayable) {

                $attribute = $attribute->toArray();

            } elseif (is_array($attribute)) {

                $attribute = $this->recursiveToArray($attribute);
            }

            $array[$key] = $attribute;
        }

        return $array;
    }
533407
final public function toArray()
    {
        $this->checkRequiredFields();

        $fields = get_object_vars($this);

        $array = [];
        foreach ($fields as $field => $value) {
            $array[$field] = $this->transformToArray($this->getAttribute($field));
        }

        return $array;
    }
398831
public function toArray()
    {
        return array_map(function($value) {
            return $value instanceof ArrayInterface ? $value->toArray() : $value;
        }, $this->attributes);
    }
1161453
public function toArray()
    {
        $attr = !empty($this->getWarden()) ? $this->getWarden() : null;
        if (empty($attr)) {
            $attr = empty($this->getVisible()) ? $this->getFillable() : $this->getVisible();
        }
        $returnable = [];

        $f_model = \FormModel::using('plain')->withModel($this);
        foreach ($attr as $old => $new) {
            if (!empty($relations = $f_model->getRelationalDataAndModels($this, $old))) {
                $returnable[$new] = $relations;
            }
            if (stripos($old, '_id') !== false) {
                if (!empty($this->$new)) {
                    $returnable[$new] = $relations;
                }
            } else {
                if (isset($this->$old)) {
                    $returnable[$new] = $this->$old;
                }
            }
        }

        return $returnable;
    }
1196341
public function toArray()
    {
        return [
            'id' => $this->id,
            'terms' => $this->terms,
            'descriptor' => $this->descriptor,
            'subdescriptor' => $this->subdescriptor,
            'score' => $this->score,
        ];
    }