Support the ongoing development of Laravel.io →
Database Eloquent Validation
Last updated 2 years ago.
0

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!

Last updated 2 years ago.
0

Thank you!

Last updated 2 years ago.
0

Here is my solution for laravel 5:

  • comment 'Illuminate\Validation\ValidationServiceProvider' in config/app.php
  • create your own DatabasePresenceVerifier on your app folder that extends the PresenceVerifier like this
namespace App\Model;
use Illuminate\Validation\PresenceVerifierInterface;
class NewPresenceVerifier implements PresenceVerifierInterface {
	// Override required methods here
}
  • Create your own ValidationServiceProvider that extends Illuminate ValidationServiceProvider like this
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();
		});
	}
}
  • Then register the new ValidationServiceProvider in config/app.php
'App\Providers\ValidationServiceProvider'
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

SynRJ synrj Joined 3 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.