First Commit

This commit is contained in:
marco
2026-09-04 14:54:13 -03:00
commit 9c54bd3ac7
4914 changed files with 789004 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
namespace Illuminate\Database\Eloquent\Relations\Concerns;
use BackedEnum;
use Doctrine\Instantiator\Exception\InvalidArgumentException;
trait InteractsWithDictionary
{
/**
* Get a dictionary key attribute - casting it to a string if necessary.
*
* @param mixed $attribute
* @return mixed
*
* @throws \Doctrine\Instantiator\Exception\InvalidArgumentException
*/
protected function getDictionaryKey($attribute)
{
if (is_object($attribute)) {
if (method_exists($attribute, '__toString')) {
return $attribute->__toString();
}
if (function_exists('enum_exists') &&
$attribute instanceof BackedEnum) {
return $attribute->value;
}
throw new InvalidArgumentException('Model attribute value is an object but does not have a __toString method.');
}
return $attribute;
}
}