Checks to see if a particular field exists in a model's schema. Can check a single field, or return the first field found in an array of multiple options.

Parameters

  • mixed $field A single field (string) or list of fields (array) to check the existence of.

Returns

mixed If `$field` is a string, returns a boolean indicating whether or not that field exists. If `$field` is an array, returns the first field found, or `false` if none of the fields in the list are found.

Source

						public static function hasField($field) {
		if (is_array($field)) {
			foreach ($field as $f) {
				if (static::hasField($f)) {
					return $f;
				}
			}
			return false;
		}
		$schema = static::schema();
		return ($schema && isset($schema[$field]));
	}