-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Closed
Closed
Copy link
Description
- Laravel Version: 5.5.43
- PHP Version: 7.2.7
- Database Driver & Version: Mysql 5.7
Description:
Morph relationships �does't support camel case database field name;
Steps To Reproduce:
this problem is because line in MorphToMany class
public function __construct(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
$relatedPivotKey, $parentKey, $relatedKey, $relationName = null, $inverse = false)
{
$this->inverse = $inverse;
$this->morphType = $name.'_type'; // Notice: problem here
$this->morphClass = $inverse ? $query->getModel()->getMorphClass() : $parent->getMorphClass();
parent::__construct(
$query, $parent, $table, $foreignPivotKey,
$relatedPivotKey, $parentKey, $relatedKey, $relationName
);
}And line in HasRelationships trait
protected function getMorphs($name, $type, $id)
{
return [$type ?: $name.'_type', $id ?: $name.'_id']; // Notice: problem here
}I think if we can add a configration in global database config file, like 'field_name_case'; and values can be snake or camel ?
Metadata
Metadata
Assignees
Labels
No labels