Skip to content

Commit c64dc03

Browse files
pi0jenssegers
authored andcommitted
Filling with Dot-Notation (#926)
* Filling with Dot-Notation Keys Simply override `removeTableFromKey($key)` method and just return original keys in order to support dot-notation when calling `fill` on model. * Style CI * Dot-Notation Fill Tests
1 parent 0f2520f commit c64dc03

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Jenssegers/Mongodb/Eloquent/Model.php

+11
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,17 @@ protected function newBaseQueryBuilder()
535535

536536
return new QueryBuilder($connection, $connection->getPostProcessor());
537537
}
538+
539+
/**
540+
* We just return original key here in order to support keys in dot-notation
541+
*
542+
* @param string $key
543+
* @return string
544+
*/
545+
protected function removeTableFromKey($key)
546+
{
547+
return $key;
548+
}
538549

539550
/**
540551
* Handle dynamic method calls into the method.

tests/ModelTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,13 @@ public function testDotNotation()
486486
$this->assertEquals('Paris', $user->getAttribute('address.city'));
487487
$this->assertEquals('Paris', $user['address.city']);
488488
$this->assertEquals('Paris', $user->{'address.city'});
489+
490+
// Fill
491+
$user->fill([
492+
'address.city' => 'Strasbourg',
493+
]);
494+
495+
$this->assertEquals('Strasbourg', $user['address.city']);
489496
}
490497

491498
public function testGetDirtyDates()

0 commit comments

Comments
 (0)