mardi 2 juillet 2019

DropDown: Validate 2 items on 3 only

I have 2 tables, the first is Students with 3 fields (name, firstname, fk_diploma).Then, my second table is named Diplomas and there is 1 field named (type_diploma).

For information, I have 3 values in my field type_diploma:

1) DiplomaA
2) DiplomaB
3) DiplomaC

In my validate system, I want the DiplomaA or DiplomaB to be validated but not the DiplomaC, I must have an error message.

For example: * "Sorry, you do not have the skills for the diplomaC."

Do you have an idea of how I can do that ?

public function store(dateRequest $request)
    {      
       $exists = Student::where('name', $request->get('name'))->where('firstname', $request->get('firstname'))->where('fk_diploma', $request->get('fk_diploma'))->count();

       if (!$exists){
            Student::create($request->all());
            return redirect()->route('students.index')
                ->with('success', 'new data created successfully');
        }

        else{
            return redirect()->route('students.index')
                ->with('error', 'duplicate');

        }   

}

enter image description here

Aucun commentaire:

Enregistrer un commentaire