-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Open
Labels
Description
Laravel Version
12.43.1
PHP Version
8.5
Database Driver & Version
Postgres 16
Description
DEPRECATED Using null as an array offset is deprecated, use an empty string instead in vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php on line 160.
Steps To Reproduce
Sometimes parent_guid is null and I have DEPRECATED warning
public function parent(): HasMany
{
return $this->hasMany(self::class, 'external_guid', 'parent_guid');
}Deprecated code (HasOneOrMany.php)
protected function matchOneOrMany(array $models, EloquentCollection $results, $relation, $type)
{
$dictionary = $this->buildDictionary($results);
//...
foreach ($models as $model) {
// When $key is null - DEPRECATED warning
if (isset($dictionary[$key = $this->getDictionaryKey($model->getAttribute($this->localKey))])) {
//...
}
}
return $models;
}Updated code (HasOneOrMany.php)
protected function matchOneOrMany(array $models, EloquentCollection $results, $relation, $type)
{
$dictionary = $this->buildDictionary($results);
//...
foreach ($models as $model) {
$key = $this->getDictionaryKey($model->getAttribute($this->localKey));
if ($key === null) {
$key = '';
}
if (isset($dictionary[$key])) {
//...
}
}
return $models;
}