mercredi 3 juillet 2019

Dropdownlist and validation

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 records in my field type_diploma:

1) DiplomaA
2) DiplomaB
3) DiplomaC

In my validate system, the User can choose the DiplomaA or DiplomaB but not the DiplomaC, If the user chooses DiplomaC, an error message appears

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

enter image description here

is there a solution in laravel?

public function store(studentRequest $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');

        }   

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire