Skip to content

Commit

Permalink
Merge pull request #43 from rene-springmann/master
Browse files Browse the repository at this point in the history
Added Laravel 5.4 compatibility
  • Loading branch information
bllim authored May 25, 2017
2 parents 5dac3ce + fb772b5 commit 2a9bc01
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"php": ">=5.3.0",
"laravelcollective/html": "5.*",
"laravelcollective/html": "^5.4",
"illuminate/support": ">=4.2",
"illuminate/validation": ">=4.0",
"illuminate/routing": ">=4.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Bllim/Laravalid/Converter/JqueryValidation/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function ip($parsedRule, $attribute, $type)

public function same($parsedRule, $attribute, $type)
{
$message = Lang::get('validation.'.$parsedRule['name'], ['attribute' => $attribute]);
$message = Helper::getValidationMessage($attribute, $parsedRule['name'], ['other' => $parsedRule['parameters'][0]]);

return ['data-msg-equalto' => $message];
}
Expand Down
4 changes: 2 additions & 2 deletions src/Bllim/Laravalid/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class FormBuilder extends \Collective\Html\FormBuilder
{
protected $converter;

public function __construct(\Collective\Html\HtmlBuilder $html, \Illuminate\Routing\UrlGenerator $url, $csrfToken, Converter\Base\Converter $converter)
public function __construct(\Collective\Html\HtmlBuilder $html, \Illuminate\Routing\UrlGenerator $url, \Illuminate\View\Factory $view, $csrfToken, Converter\Base\Converter $converter)
{
parent::__construct($html, $url, $csrfToken);
parent::__construct($html, $url, $view, $csrfToken);
$plugin = \Config::get('laravalid.plugin');
$this->converter = $converter;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Bllim/Laravalid/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public static function getValidationMessage($attribute, $rule, $data = [], $type
}

$niceName = !\Lang::has('validation.attributes.'.$attribute) ? $attribute : \Lang::get('validation.attributes.'.$attribute);

//reform data so that all fields have nice names
foreach ($data as $key => $fieldName) {
$data[$key] = !\Lang::has('validation.attributes.'.$fieldName) ? $fieldName : \Lang::get('validation.attributes.'.$fieldName);
}

return \Lang::get('validation.'.$path, $data + ['attribute' => $niceName]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bllim/Laravalid/LaravalidServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function register()
$converterClassName = 'Bllim\Laravalid\Converter\\'.$plugin.'\Converter';
$converter = new $converterClassName();

$form = new FormBuilder($app->make('html'), $app->make('url'), $app->make('session.store')->getToken(), $converter);
$form = new FormBuilder($app->make('html'), $app->make('url'), $app->make('view'), $app->make('session.store')->token(), $converter);

return $form->setSessionStore($app->make('session.store'));
}
Expand Down

0 comments on commit 2a9bc01

Please sign in to comment.