From a3d42da280c6927bc6df7b04ce3f9fdd5a05e461 Mon Sep 17 00:00:00 2001 From: Adrian Gunawan Date: Sat, 14 May 2016 20:50:52 +1000 Subject: [PATCH 1/6] Transform the field name when getting the form value from model --- src/FormBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FormBuilder.php b/src/FormBuilder.php index a6ebd53..52390a7 100755 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -1103,7 +1103,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)); From 0625f71fd937572cf7c49bf5f05e883224803410 Mon Sep 17 00:00:00 2001 From: Adrian Gunawan Date: Thu, 19 May 2016 14:39:49 +1000 Subject: [PATCH 2/6] Fix the issue of getting form value from related model --- src/Eloquent/FormAccessible.php | 4 ++++ tests/FormAccessibleTest.php | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Eloquent/FormAccessible.php b/src/Eloquent/FormAccessible.php index b54bffe..a930e51 100644 --- a/src/Eloquent/FormAccessible.php +++ b/src/Eloquent/FormAccessible.php @@ -39,6 +39,10 @@ trait FormAccessible // retrieval from the model to a form that is more useful for usage. if ($this->hasFormMutator($key)) { return $this->mutateFormAttribute($key, $value); + } else { + + // No form mutator, let the model resolve this + return data_get($this, $key); } return $value; diff --git a/tests/FormAccessibleTest.php b/tests/FormAccessibleTest.php index 77d9524..db71bed 100644 --- a/tests/FormAccessibleTest.php +++ b/tests/FormAccessibleTest.php @@ -25,6 +25,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, ]; @@ -44,6 +47,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); From 71b81b7f9645aab5b569494deef6560a979f68e4 Mon Sep 17 00:00:00 2001 From: Adrian Gunawan Date: Thu, 30 Jun 2016 20:59:34 +1000 Subject: [PATCH 3/6] Remove unreachable return statement --- src/Eloquent/FormAccessible.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Eloquent/FormAccessible.php b/src/Eloquent/FormAccessible.php index a930e51..5a42608 100644 --- a/src/Eloquent/FormAccessible.php +++ b/src/Eloquent/FormAccessible.php @@ -39,13 +39,10 @@ trait FormAccessible // retrieval from the model to a form that is more useful for usage. if ($this->hasFormMutator($key)) { return $this->mutateFormAttribute($key, $value); - } else { - - // No form mutator, let the model resolve this - return data_get($this, $key); } - return $value; + // No form mutator, let the model resolve this + return data_get($this, $key); } /** From eb132aed5c28dc0936b99534a445208b53511d77 Mon Sep 17 00:00:00 2001 From: rajatsharma94 Date: Mon, 11 Jul 2016 11:47:54 +0530 Subject: [PATCH 4/6] added nbsp() to generate repeated   tag --- src/HtmlBuilder.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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. * From c4c87916c34e04aa9d4e860315ab1858304d786a Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Wed, 3 Aug 2016 22:49:50 -0500 Subject: [PATCH 5/6] Updating for 5.3 --- .travis.yml | 2 +- composer.json | 26 ++++++++++++++++---------- src/Eloquent/FormAccessible.php | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) 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..f44eca2 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": { @@ -37,5 +37,11 @@ "files": [ "src/helpers.php" ] - } + }, + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "minimum-stability": "dev" } diff --git a/src/Eloquent/FormAccessible.php b/src/Eloquent/FormAccessible.php index 5a42608..a3632c8 100644 --- a/src/Eloquent/FormAccessible.php +++ b/src/Eloquent/FormAccessible.php @@ -55,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'; }); From 961ce141c16c6b085128f209496c26efd3e681ca Mon Sep 17 00:00:00 2001 From: Adam Engebretson Date: Sat, 27 Aug 2016 18:52:43 -0500 Subject: [PATCH 6/6] v5.3.0 --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index f44eca2..813db5f 100755 --- a/composer.json +++ b/composer.json @@ -37,11 +37,5 @@ "files": [ "src/helpers.php" ] - }, - "extra": { - "branch-alias": { - "dev-master": "5.3-dev" - } - }, - "minimum-stability": "dev" + } }