Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
peripherad
/
vendor
/
laravel
/
framework
/
src
/
Illuminate
/
Database
/
Eloquent
/
Relations
/
Concerns
:
InteractsWithDictionary.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Illuminate\Database\Eloquent\Relations\Concerns; use BackedEnum; use Doctrine\Instantiator\Exception\InvalidArgumentException; use UnitEnum; 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 UnitEnum) { return $attribute instanceof BackedEnum ? $attribute->value : $attribute->name; } throw new InvalidArgumentException('Model attribute value is an object but does not have a __toString method.'); } return $attribute; } }