diff --git a/.travis.yml b/.travis.yml index c574333..9812b0f 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: php php: - - 5.5 - 5.6 - 7.0 + - 7.1 - hhvm sudo: false diff --git a/composer.json b/composer.json index e8461cf..813db5f 100755 --- a/composer.json +++ b/composer.json @@ -18,17 +18,17 @@ } ], "require": { - "php": ">=5.5.9", - "illuminate/http": "5.2.*", - "illuminate/routing": "5.2.*", - "illuminate/session": "5.2.*", - "illuminate/support": "5.2.*", - "illuminate/view": "5.2.*" + "php": ">=5.6.4", + "illuminate/http": "5.3.*", + "illuminate/routing": "5.3.*", + "illuminate/session": "5.3.*", + "illuminate/support": "5.3.*", + "illuminate/view": "5.3.*" }, "require-dev": { - "illuminate/database": "5.2.*", - "mockery/mockery": "~0.9", - "phpunit/phpunit": "~4.0" + "illuminate/database": "5.3.*", + "mockery/mockery": "~0.9.4", + "phpunit/phpunit": "~5.4" }, "autoload": { "psr-4": { diff --git a/src/Eloquent/FormAccessible.php b/src/Eloquent/FormAccessible.php index b54bffe..a3632c8 100644 --- a/src/Eloquent/FormAccessible.php +++ b/src/Eloquent/FormAccessible.php @@ -41,7 +41,8 @@ trait FormAccessible return $this->mutateFormAttribute($key, $value); } - return $value; + // No form mutator, let the model resolve this + return data_get($this, $key); } /** @@ -54,7 +55,7 @@ trait FormAccessible $methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC); $mutator = collect($methods) - ->first(function ($index, ReflectionMethod $method) use ($key) { + ->first(function (ReflectionMethod $method) use ($key) { return $method->getName() == 'form' . Str::studly($key) . 'Attribute'; }); diff --git a/src/FormBuilder.php b/src/FormBuilder.php index b9ec8b4..4e7cf0f 100644 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -1107,7 +1107,7 @@ class FormBuilder protected function getModelValueAttribute($name) { if (method_exists($this->model, 'getFormValue')) { - return $this->model->getFormValue($name); + return $this->model->getFormValue($this->transformKey($name)); } return data_get($this->model, $this->transformKey($name)); diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index 037e873..7306fc4 100755 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -277,6 +277,18 @@ class HtmlBuilder return str_replace('@', '@', $this->obfuscate($email)); } + /** + * Generates non-breaking space entities based on number supplied. + * + * @param int $num + * + * @return string + */ + public function nbsp($num = 1) + { + return str_repeat(' ', $num); + } + /** * Generate an ordered list of items. * diff --git a/tests/FormAccessibleTest.php b/tests/FormAccessibleTest.php index d0490bc..9add106 100644 --- a/tests/FormAccessibleTest.php +++ b/tests/FormAccessibleTest.php @@ -24,6 +24,9 @@ class FormAccessibleTest extends PHPUnit_Framework_TestCase $this->modelData = [ 'string' => 'abcdefghijklmnop', 'email' => 'tj@tjshafer.com', + 'address' => [ + 'street' => 'abcde st' + ], 'created_at' => $this->now, 'updated_at' => $this->now, ]; @@ -43,6 +46,12 @@ class FormAccessibleTest extends PHPUnit_Framework_TestCase $this->assertEquals($model->getFormValue('created_at'), $this->now->timestamp); } + public function testItCanGetRelatedValueForForms() + { + $model = new ModelThatUsesForms($this->modelData); + $this->assertEquals($model->getFormValue('address.street'), 'abcde st'); + } + public function testItCanStillMutateValuesForViews() { $model = new ModelThatUsesForms($this->modelData);