Skip to content

Commit

Permalink
Merge pull request #310 from mauricius/issue307
Browse files Browse the repository at this point in the history
Added Laravel 5.4 compatibility
  • Loading branch information
kristijanhusak authored Jan 31, 2017
2 parents 4aebb49 + 577d4bb commit 49f7ccc
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"illuminate/validation": "5.*@dev"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"orchestra/testbench": "~3.0"
"phpunit/phpunit": "~5.0",
"orchestra/testbench": "~3.4"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Kris/LaravelFormBuilder/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Contracts\Validation\Factory as ValidatorFactory;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exception\HttpResponseException;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Kris\LaravelFormBuilder\Events\AfterFieldCreation;
Expand Down
5 changes: 4 additions & 1 deletion src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ private function registerFormIfHeeded()
// LaravelCollective\HtmlBuilder 5.2 is not backward compatible and will throw an exception
$version = substr(Application::VERSION, 0, 3);

if (str_is('5.0', $version) || str_is('5.1', $version)) {
if(str_is('5.4', $version)) {
$form = new LaravelForm($app[ 'html' ], $app[ 'url' ], $app[ 'view' ], $app[ 'session.store' ]->token());
}
else if (str_is('5.0', $version) || str_is('5.1', $version)) {
$form = new LaravelForm($app[ 'html' ], $app[ 'url' ], $app[ 'session.store' ]->getToken());
}
else {
Expand Down
6 changes: 3 additions & 3 deletions src/Kris/LaravelFormBuilder/FormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Support\Collection;
use Kris\LaravelFormBuilder\Fields\FormField;
use Kris\LaravelFormBuilder\Form;
use Symfony\Component\Translation\TranslatorInterface;
use Illuminate\Translation\Translator;

class FormHelper
{
Expand Down Expand Up @@ -87,10 +87,10 @@ class FormHelper

/**
* @param View $view
* @param TranslatorInterface $translator
* @param Translator $translator
* @param array $config
*/
public function __construct(View $view, TranslatorInterface $translator, array $config = [])
public function __construct(View $view, Translator $translator, array $config = [])
{
$this->view = $view;
$this->translator = $translator;
Expand Down
3 changes: 3 additions & 0 deletions tests/Fields/CollectionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
use Kris\LaravelFormBuilder\Fields\CollectionType;
use Kris\LaravelFormBuilder\Fields\SelectType;
use Kris\LaravelFormBuilder\Form;
use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;

class CollectionTypeTest extends FormBuilderTestCase
{
use InteractsWithSession;

/** @test */
public function it_creates_collection()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/FormBuilderTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function setUp()
$this->view = $this->app['view'];
$this->translator = $this->app['translator'];
$this->request = $this->app['request'];
$this->request->setSession($this->app['session.store']);
$this->request->setLaravelSession($this->app['session.store']);
$this->validatorFactory = $this->app['validator'];
$this->eventDispatcher = $this->app['events'];
$this->model = new TestModel();
Expand Down
2 changes: 1 addition & 1 deletion tests/FormTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Illuminate\Http\Exception\HttpResponseException;
use Illuminate\Http\Exceptions\HttpResponseException;
use Kris\LaravelFormBuilder\Events\AfterFormValidation;
use Kris\LaravelFormBuilder\Events\BeforeFormValidation;
use Kris\LaravelFormBuilder\Fields\InputType;
Expand Down

0 comments on commit 49f7ccc

Please sign in to comment.