-
Type: Question
-
Resolution: Cannot Reproduce
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Laravel
clarkeash has created Issue #2725: First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null" in laravel-mongodb. This Jira ticket was filed by GromNaN
Issue Text:
- Laravel-mongodb Version: 4.1.1
- PHP Version: 8.3.2
- Database Driver & Version: 1.17.2
Description: I am currently upgrading to Laravel 10 and v4 of this library and when calling save on an embeded document I get the error: `First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null"`
Steps to reproduce
I have the following models (simplified for clarity)
```php
class Account extends Model {
public function stripe(): EmbedsOne
}
```
```php
class Stripe extends Model {}
```
Then when I try to update the stripe subdocument like so:
```php
$account = Account::find(...);
$stripe = $account->stripe;
$stripe->subscription = ['some data'];
$stripe->save();
```
Expected behaviour
Tell us what should happen `jenssegers/mongodb` 3.9 it would save the data just fine.
Actual behaviour
```
1) Tests\Feature\Actions\Stripe\CancelPendingChangeTest::it_will_cancel_a_pending_modification
InvalidArgumentException: First argument of MongoDB\Laravel\Query\Builder::where must be a field path as "string". Got "null"
/Users/clarkeash/code/sites/billing/vendor/mongodb/laravel-mongodb/src/Query/Builder.php:1012
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:302
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1254
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1213
/Users/clarkeash/code/sites/billing/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1130
/Users/clarkeash/code/sites/billing/vendor/mongodb/laravel-mongodb/src/Eloquent/Model.php:737
/Users/clarkeash/code/sites/billing/app/Actions/Stripe/StoreSubscriptionInformation.php:82
/Users/clarkeash/code/sites/billing/vendor/lorisleiva/laravel-actions/src/Concerns/AsObject.php:24
/Users/clarkeash/code/sites/billing/tests/Feature/Actions/Stripe/CancelPendingChangeTest.php:41
```
I am unsure if this is a bug or if I have missed something, can you point me in the right direction? Thanks