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');

        }   

}



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

Aucun commentaire:

Enregistrer un commentaire