dimanche 24 juillet 2016

Laravel5.2 custom array vlaidation

I have the following problem, I added a costume validation rule with the following code:

Validator::extend('valid_map',function($attributes,$value,$parameters){

          return !\DB::table('students')
        ->join('institute_level', 'institute_level.id', '=', 'students.institute_level_id')
        ->where('institute_level_id',$parameters[0])
        ->where('students.id',$value)
        ->first();
        });

the problem is that I want to pass in the $parameters[0] some value from an array like this:

'levelclasses.*.class.*.student_id' =>
'integer|exist:\App\Student|valid_map:levelclasses.*.level_id'

this case work successfully with the rules that came with Laravel, now I want this case to work in my rule. any suggestions ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2amMhC5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire