Support the ongoing development of Laravel.io →
Requests Forms Validation
Last updated 1 year ago.
0

Change to:

public function rules()
    {
        return [
        "studentId" => "required | numeric | unique:students,studentId,".$this->route('id'),
        "ssn"       => "required | numeric | unique:students,ssn,".$this->route('id'),
        "epsbId"    => "required | numeric | unique:students,epsbId,".$this->route('id'),
        "first"     => "required",
        "last"      => "required",
        "gender"    => "required", 
        "ethnicity" => "required",
        "email"     => "email",
        "birthdate" => "date"      
        ];
    }
0

Thanks for the response. I tried this and got the same results. I am at a complete loss on this one.

Any other ideas? Something silly I am missing?

0

is it because those rules are being applied to the update but are really for when you ADD a new user..

wasnt there a way of differentiating rules between add/update?

0

you are absolutely right. I don't know if it needs to be a separate Request or there is some other means to dynamically change the rules.

I am also not totally sure I have the unique rules setup correctly above. I have tried many different variations of code to add the id parameter to the unique check, but none of them seem to make any difference.

Seems like there will also need to be checks put in to see if the unique fields change. If they change, then the unique validation will need to be checked again.

oh the headaches.

0

use $this->route('students')

0
1> add on the top of CreatestudentRequest  (model name)
     App/Student
2>in ur rule define this



    if( $this->get('_method') ==='PATCH')
    {
        $user_id=$this->get('user_id');
        $id= Student::where( 'user_id' , $user_id )->first()->id;
    }
    else
        $id=' ';
3> change field values into
"studentId" => "required | numeric | unique:students,studentId,".$id,
"ssn"       => "required | numeric | unique:students,ssn,".$id,
"epsbId"    => "required | numeric | unique:students,epsbId,".$id,
4> if you have any exception for any of youre app just use these var_dump() | var_export() | dd()
      to know about the errors
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kirchaj kirchaj Joined 1 Jul 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.