|
6 | 6 | use GearboxSolutions\EloquentFileMaker\Database\Eloquent\Relations\BelongsTo; |
7 | 7 | use GearboxSolutions\EloquentFileMaker\Database\Eloquent\Relations\HasMany; |
8 | 8 | use GearboxSolutions\EloquentFileMaker\Database\Eloquent\Relations\HasOne; |
| 9 | +use GearboxSolutions\EloquentFileMaker\Database\Eloquent\Relations\MorphTo; |
9 | 10 | use Illuminate\Database\Eloquent\Builder; |
10 | 11 | use Illuminate\Database\Eloquent\Concerns\HasRelationships; |
11 | 12 | use Illuminate\Database\Eloquent\Model; |
@@ -133,6 +134,22 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey = |
133 | 134 | return $this->newMorphMany($instance->newQuery(), $this, $type, $id, $localKey); |
134 | 135 | } |
135 | 136 |
|
| 137 | + /** |
| 138 | + * Instantiate a new MorphTo relationship. Normally we would handle the resolution of the method here, |
| 139 | + * but we don't know yet if the related Modal is an FMModel or Eloquent model. We will let the FM MorphTo |
| 140 | + * class handle it. |
| 141 | + * |
| 142 | + * @param string $foreignKey |
| 143 | + * @param string $ownerKey |
| 144 | + * @param string $type |
| 145 | + * @param string $relation |
| 146 | + * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
| 147 | + */ |
| 148 | + protected function newMorphTo(Builder $query, Model $parent, $foreignKey, $ownerKey, $type, $relation) |
| 149 | + { |
| 150 | + return new MorphTo($query, $parent, $foreignKey, $ownerKey, $type, $relation); |
| 151 | + } |
| 152 | + |
136 | 153 | /** |
137 | 154 | * Instantiate a new HasOne relationship. |
138 | 155 | * |
|
0 commit comments