diff --git a/src/Fields/Relations/BelongsTo.php b/src/Fields/Relations/BelongsTo.php index c8f97a8..dad2dfd 100644 --- a/src/Fields/Relations/BelongsTo.php +++ b/src/Fields/Relations/BelongsTo.php @@ -58,7 +58,7 @@ public function fill(Model $model, ?array $identifier): void { $name = $this->relationName(); - assert(method_exists($model, $name), sprintf( + assert(method_exists($model, $name) || $model->relationResolver($model::class, $name), sprintf( 'Expecting method %s to exist on model %s.', $name, $model::class, diff --git a/src/Fields/Relations/BelongsToMany.php b/src/Fields/Relations/BelongsToMany.php index 541a3b2..e940482 100644 --- a/src/Fields/Relations/BelongsToMany.php +++ b/src/Fields/Relations/BelongsToMany.php @@ -150,7 +150,7 @@ private function getRelation(Model $model): EloquentBelongsToMany { $name = $this->relationName(); - assert(method_exists($model, $name), sprintf( + assert(method_exists($model, $name) || $model->relationResolver($model::class, $name), sprintf( 'Expecting method %s to exist on model %s.', $name, $model::class, diff --git a/src/Fields/Relations/HasMany.php b/src/Fields/Relations/HasMany.php index 56b04b9..3ebd37b 100644 --- a/src/Fields/Relations/HasMany.php +++ b/src/Fields/Relations/HasMany.php @@ -159,7 +159,7 @@ private function getRelation(Model $model): EloquentHasMany|EloquentMorphMany { $name = $this->relationName(); - assert(method_exists($model, $name), sprintf( + assert(method_exists($model, $name) || $model->relationResolver($model::class, $name), sprintf( 'Expecting method %s to exist on model %s.', $name, $model::class, diff --git a/src/Fields/Relations/HasOne.php b/src/Fields/Relations/HasOne.php index f4c9968..4901528 100644 --- a/src/Fields/Relations/HasOne.php +++ b/src/Fields/Relations/HasOne.php @@ -100,7 +100,7 @@ public function fill(Model $model, ?array $identifier): void { $name = $this->relationName(); - assert(method_exists($model, $name), sprintf( + assert(method_exists($model, $name) || $model->relationResolver($model::class, $name), sprintf( 'Expecting method %s to exist on model %s.', $name, $model::class, diff --git a/src/QueryToMany.php b/src/QueryToMany.php index 4c201b1..e412e63 100644 --- a/src/QueryToMany.php +++ b/src/QueryToMany.php @@ -152,7 +152,7 @@ private function getRelation(): EloquentRelation { $name = $this->relation->relationName(); - assert(method_exists($this->model, $name), sprintf( + assert(method_exists($this->model, $name) || $this->model->relationResolver($this->model::class, $name), sprintf( 'Expecting method %s to exist on model %s', $name, $this->model::class, diff --git a/src/QueryToOne.php b/src/QueryToOne.php index ec5d342..fceb903 100644 --- a/src/QueryToOne.php +++ b/src/QueryToOne.php @@ -90,7 +90,7 @@ private function getRelation(): EloquentRelation { $name = $this->relation->relationName(); - assert(method_exists($this->model, $name), sprintf( + assert(method_exists($this->model, $name) || $this->model->relationResolver($this->model::class, $name), sprintf( 'Expecting method %s to exist on model %s', $name, $this->model::class,