You probably just need to tell the Validator
what connection you are using. This can be done using the setPresenceVerifier
method. Here is a code example:
// Create a new instance of the presence verifier. Let's make the IoC do the work.
$verifier = App::make('validation.presence');
// Set the connection on the verifier.
$verifier->setConnection($connection);
// Create the validator instance (your code)
$rules = Admin::$rules;
$validator = Validator::make(Input::all(), $rules);
// Set the validator's presence verifier.
$validator->setPresenceVerifier($verifier);
In the above code, $connection
is the connection/schema name (fo
or bo
). Good luck!
Here is my solution for laravel 5:
namespace App\Model;
use Illuminate\Validation\PresenceVerifierInterface;
class NewPresenceVerifier implements PresenceVerifierInterface {
// Override required methods here
}
namespace App\Providers;
use App\Model\NewPresenceVerifier;
use Illuminate\Validation\ValidationServiceProvider as BaseValidationServiceProvider;
class ValidationServiceProvider extends BaseValidationServiceProvider {
protected function registerPresenceVerifier()
{
$this->app->singleton('validation.presence', function($app)
{
return new NewPresenceVerifier();
});
}
}
'App\Providers\ValidationServiceProvider'
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community