You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There has been working support for morphTo relations, but that seems to break after upgrading from 4.0 to 4.1.
Steps to reproduce
You need to have model with morphTo relationship. Here is my "Subscription" model (it does extend mongo model, leaving namespaces out for simpllicity):
class Subscription extends Model
{
use HasFactory;
public function subscribable(): MorphTo
{
return $this->morphTo();
}
public function user()
{
return $this->belongsTo(User::class);
}
}
When using the relationship it fails. This is how this is used in our codebase (controller):
$subscription = new Subscription();
$subscription->user()->associate($user);
$subscription->subscribable()->associate($thread);
$subscription->save();
Expected behaviour
New subscription should be saved to database with this kind of values:
I also noticed that MorphTo relations are not listed as supported relations on the readme. They have worked nicely before though - so is it safe to assume these will be supported in the future too? Because if not, this would mean migrating away from Mongo in our current project.
Thanks for your feedback @apeisa, it's great to have contributors testing development branches. It helps us deliver stable releases without regression.
We're going to make sure there's no regression with MorphTo. This feature will be covered by tests from now on.
Description:
There has been working support for morphTo relations, but that seems to break after upgrading from 4.0 to 4.1.
Steps to reproduce
Expected behaviour
New subscription should be saved to database with this kind of values:
Actual behaviour
InvalidArgumentException is thrown:
First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null"
Here is more detailed stacktrace: https://flareapp.io/share/bP99dGOP
The text was updated successfully, but these errors were encountered: