Skip to content

Commit 49f7ccc

Browse files
Merge pull request #310 from mauricius/issue307
Added Laravel 5.4 compatibility
2 parents 4aebb49 + 577d4bb commit 49f7ccc

File tree

7 files changed

+15
-9
lines changed

7 files changed

+15
-9
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"illuminate/validation": "5.*@dev"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "~4.0",
19-
"orchestra/testbench": "~3.0"
18+
"phpunit/phpunit": "~5.0",
19+
"orchestra/testbench": "~3.4"
2020
},
2121
"extra": {
2222
"branch-alias": {

src/Kris/LaravelFormBuilder/Form.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
44
use Illuminate\Contracts\Validation\Factory as ValidatorFactory;
55
use Illuminate\Contracts\Validation\Validator;
6-
use Illuminate\Http\Exception\HttpResponseException;
6+
use Illuminate\Http\Exceptions\HttpResponseException;
77
use Illuminate\Http\Request;
88
use Illuminate\Support\Arr;
99
use Kris\LaravelFormBuilder\Events\AfterFieldCreation;

src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ private function registerFormIfHeeded()
8989
// LaravelCollective\HtmlBuilder 5.2 is not backward compatible and will throw an exception
9090
$version = substr(Application::VERSION, 0, 3);
9191

92-
if (str_is('5.0', $version) || str_is('5.1', $version)) {
92+
if(str_is('5.4', $version)) {
93+
$form = new LaravelForm($app[ 'html' ], $app[ 'url' ], $app[ 'view' ], $app[ 'session.store' ]->token());
94+
}
95+
else if (str_is('5.0', $version) || str_is('5.1', $version)) {
9396
$form = new LaravelForm($app[ 'html' ], $app[ 'url' ], $app[ 'session.store' ]->getToken());
9497
}
9598
else {

src/Kris/LaravelFormBuilder/FormHelper.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Support\Collection;
88
use Kris\LaravelFormBuilder\Fields\FormField;
99
use Kris\LaravelFormBuilder\Form;
10-
use Symfony\Component\Translation\TranslatorInterface;
10+
use Illuminate\Translation\Translator;
1111

1212
class FormHelper
1313
{
@@ -87,10 +87,10 @@ class FormHelper
8787

8888
/**
8989
* @param View $view
90-
* @param TranslatorInterface $translator
90+
* @param Translator $translator
9191
* @param array $config
9292
*/
93-
public function __construct(View $view, TranslatorInterface $translator, array $config = [])
93+
public function __construct(View $view, Translator $translator, array $config = [])
9494
{
9595
$this->view = $view;
9696
$this->translator = $translator;

tests/Fields/CollectionTypeTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
use Kris\LaravelFormBuilder\Fields\CollectionType;
55
use Kris\LaravelFormBuilder\Fields\SelectType;
66
use Kris\LaravelFormBuilder\Form;
7+
use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;
78

89
class CollectionTypeTest extends FormBuilderTestCase
910
{
11+
use InteractsWithSession;
12+
1013
/** @test */
1114
public function it_creates_collection()
1215
{

tests/FormBuilderTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function setUp()
7777
$this->view = $this->app['view'];
7878
$this->translator = $this->app['translator'];
7979
$this->request = $this->app['request'];
80-
$this->request->setSession($this->app['session.store']);
80+
$this->request->setLaravelSession($this->app['session.store']);
8181
$this->validatorFactory = $this->app['validator'];
8282
$this->eventDispatcher = $this->app['events'];
8383
$this->model = new TestModel();

tests/FormTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use Illuminate\Http\Exception\HttpResponseException;
3+
use Illuminate\Http\Exceptions\HttpResponseException;
44
use Kris\LaravelFormBuilder\Events\AfterFormValidation;
55
use Kris\LaravelFormBuilder\Events\BeforeFormValidation;
66
use Kris\LaravelFormBuilder\Fields\InputType;

0 commit comments

Comments
 (0)