Skip to content

Filling with Dot-Notation #926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Jenssegers/Mongodb/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ protected function newBaseQueryBuilder()

return new QueryBuilder($connection, $connection->getPostProcessor());
}

/**
* We just return original key here in order to support keys in dot-notation
*
* @param string $key
* @return string
*/
protected function removeTableFromKey($key)
{
return $key;
}

/**
* Handle dynamic method calls into the method.
Expand Down
7 changes: 7 additions & 0 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,13 @@ public function testDotNotation()
$this->assertEquals('Paris', $user->getAttribute('address.city'));
$this->assertEquals('Paris', $user['address.city']);
$this->assertEquals('Paris', $user->{'address.city'});

// Fill
$user->fill([
'address.city' => 'Strasbourg',
]);

$this->assertEquals('Strasbourg', $user['address.city']);
}

public function testGetDirtyDates()
Expand Down