Skip to content

Commit a568cdc

Browse files
committed
create axios put and update student
1 parent 8600eca commit a568cdc

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

app/Http/Controllers/StudentController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ public function edit_student($id){
2424
$student = Student::find($id);
2525
return response()->json($student);
2626
}
27+
public function update_student(){
28+
return 'test';
29+
}
2730
}

public/js/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,13 @@ __webpack_require__.r(__webpack_exports__);
21802180
},
21812181
updateStudent: function updateStudent() {
21822182
console.log(this.id);
2183+
axios.put("update_student", {
2184+
name: this.edit_name,
2185+
email: this.edit_email,
2186+
phone: this.edit_phone
2187+
}).then(function (response) {
2188+
return console.log(response);
2189+
});
21832190
}
21842191
}
21852192
});

resources/js/components/CreateComponent.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ export default {
222222
},
223223
updateStudent(){
224224
console.log(this.id);
225+
axios.put("update_student" , {
226+
name: this.edit_name,
227+
email: this.edit_email,
228+
phone: this.edit_phone,
229+
})
230+
.then(response => console.log(response));
225231
},
226232
},
227233
};

routes/web.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
Route::get('/home', 'HomeController@index')->name('home');
2121
Route::post('save_student', 'StudentController@save_student');
2222
Route::get('all_students', 'StudentController@all_students');
23-
Route::get('edit_student/{id}', 'StudentController@edit_student');
23+
Route::get('edit_student/{id}', 'StudentController@edit_student');
24+
Route::get('update_student', 'StudentController@update_student');

0 commit comments

Comments
 (0)