Closed
Description
morphTo relation is not being properly loaded when type and id of related model is null.
Example:
class Photo extends \Eloquent {
public function imageable() {
return $this->morphTo();
}
}
class Staff extends \Eloquent {
public function photos() {
return $sthis->morphMany('Photo', 'imageable');
}
}
// when creating new model
$photo = new Photo();
print $photo->imageable()->toSql();
// prints: select * from `photos` where `photos`.`` is null
// when loading existing model with imageable_type===null
print Photo::find(1)->imageable()->toSql();
// prints: select * from `photos` where `photos`.`` is null
// ... or
print Photo::find(1)->imageable;
// expect null, instead exception is thrown (bad query as seen in previous two examples)
Metadata
Metadata
Assignees
Labels
No labels