I have same issue likes @ChrisBinge's issue..
I have been registered my validation class that extends laravel validation class.
<?php namespace Muratsplat\Multilang;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Muratsplat\Multilang\Picker;
use Muratsplat\Multilang\Validator;
use Muratsplat\Multilang\NewRules;
use Muratsplat\Multilang\Wrapper;
/* MultiLang Service Provider
*
* @author Murat Ödünç <[email protected]>
* @copyright (c) 2015, Murat Ödünç
* @link https://github.com/muratsplat/multilang Project Page
* @license http://www.gnu.org/licenses/gpl-3.0.html GPLv3
*/
class MultilangServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('muratsplat/multilang');
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
// adding new rules for our extention
$this->addNewRules();
$this->app->singleton('multilang', function($app) {
return new MultiLang(
new Picker(new Collection(), new Element(),$app['config']),
$app['config'],
new MessageBag(),
new Validator($app['validator'], $app['config']),
new Wrapper($app['config'])
);
});
}
/**
* to add new rules to Laravel Validator object
*/
private function addNewRules() {
$this->app['validator']->resolver(function($translator, $data, $rules, $messages) {
return new NewRules($translator, $data, $rules, $messages);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('multilang');
}
}
When the app is runtime, it need to accass to my valdiation rules and return this error: "BadMethodCallException: Method [validateRequiredForDefaultLang] does not exist."
It looks the resolver never call the callback function ..
How should I add my validation object to laravel via IoC ?
I have solved that issue..
Validator resolver must be run inside of boot method on service provider...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community