Casts data into proper format when added to a collection or entity object.

Parameters

  • mixed $entity The entity or collection for which data is being cast, or the name of the model class to which the entity/collection is bound.
  • array $data An array of data being assigned.
  • array $options Any associated options with, for example, instantiating new objects in which to wrap the data. Options implemented by `cast()` itself: - `first` _boolean_: Used when only one value is passed to `cast()`. Even though that value must be wrapped in an array, setting the `'first'` option to `true` causes only that one value to be returned.

Returns

mixed Returns the value of `$data`, cast to the proper format according to the schema definition of the model class specified by `$model`.

Source

						public function cast($entity, array $data, array $options = array()) {
		$defaults = array('first' => false);
		$options += $defaults;
		return $options['first'] ? reset($data) : $data;
	}