Here the scenario is, I have 3 tables
: 1. Teacher.
2. Course.
3. Course Assign to Teacher
In teacher table there is two columns name: credit_taken
and remaining_credit
(default 0
) and in course there is course_credit
column. So here is problem, In course Assign to Teacher when a teacher take a course the equation would be like remaining_credit=credit_taken -course_credit
I have done the solution but instead of value update in database it's creating new teacher row in teachers table.
Here is my controller:
public function postcourseAssignTeacher(Request $request)
{
$assignTeacher = new AssignTeacher();
$assignTeacher->teacher_id=$request->Input(['teacher_id']);
$teacher->credit_taken = $request->Input(['credit_taken']);
$teacher->remaining_credit = $request->Input('remaining_credit');
$assignTeacher->course_id = $request->input('course_id');
$course->name=$request->Input('name');
$course->credit=$request->Input('credit');
$teacher->remaining_credit=$teacher->credit_taken -$course->credit;
$assignTeacher->save();
// $course->save();
$teacher->update();
return redirect('courseAssignTeacherPage');
}
How do I update above two columns in teacher table?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1W3XMyi
via IFTTT
Aucun commentaire:
Enregistrer un commentaire