I want to get the parameter passed in the validation rule.
For some validation rules that I created, I can get the parameter from the validation rule, but for several rules it does not receive the parameters.
In the model, I use the following code:
public static $rules_sponsor_event_check = array( 'sponsor_id' => 'required', 'event_id' => 'required|event_sponsor:sponsor_id' );
In ValidatorServiceProvider, I use the following code:
Validator::extend('event_sponsor', function ($attribute, $value, $parameters) { $sponsor_id = Input::get($parameters[0]); $event_sponsor = EventSponsor::whereIdAndEventId($sponsor_id, $value)->count(); if ($event_sponsor == 0) { return false; } else { return true; } });
But here I can not get the sponsor ID using the following:
$sponsor_id = Input::get($parameters[0]);
source share