How to insert data of student in 1 to 10 class tables by inserting from only one form and data should be added to any table with respect to class and each table has fields(class, student_name, roll_no, attendence). For example if field class contains data "Two" then all the data should be inserted to class two table.
The migration file is
Schema::create('students', function (Blueprint $table) {
$table->increments('id');
$table->string('class');
$table->string('student_name');
$table->integer('roll_no');
$table->string('attendence');
$table->timestamps();
});
The Route for inserting data is
Route::post('/addclass' , 'AdminController@addclass');
Controller is here
public function addclass(Request $request){
$this->validate($request , [
'class'=>'required',
'student_name'=>'required',
'roll_no'=>'required',
'attendence'=>'required',
]);
$students = new Student;
$students->class = $request->input('class');
$students->student_name = $request->input('student_name');
$students->roll_no = $request->input('roll_no');
$students->attendence = $request->input('attendence');
$students->save();
return redirect('/allstudent')->with('info','Data Added Successfuly!');
}
What changes are required in code to submit data in related table of 10 classes. Please solve my prob otherwise it will be a long work for me.maybe i have to make crud of any class which is very time consuming.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2IZoeYu
via IFTTT
Aucun commentaire:
Enregistrer un commentaire