Commit c64dc03a authored by Pooya Parsa's avatar Pooya Parsa Committed by Jens Segers

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
parent 0f2520f2
...@@ -535,6 +535,17 @@ abstract class Model extends BaseModel ...@@ -535,6 +535,17 @@ abstract class Model extends BaseModel
return new QueryBuilder($connection, $connection->getPostProcessor()); 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. * Handle dynamic method calls into the method.
......
...@@ -486,6 +486,13 @@ class ModelTest extends TestCase ...@@ -486,6 +486,13 @@ class ModelTest extends TestCase
$this->assertEquals('Paris', $user->getAttribute('address.city')); $this->assertEquals('Paris', $user->getAttribute('address.city'));
$this->assertEquals('Paris', $user['address.city']); $this->assertEquals('Paris', $user['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() public function testGetDirtyDates()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment