Skip to content

Commit 2e923aa

Browse files
committed
go list student after edit student
1 parent d02a82f commit 2e923aa

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

public/js/app.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,7 @@ __webpack_require__.r(__webpack_exports__);
21312131
//
21322132
//
21332133
//
2134+
//
21342135
/* harmony default export */ __webpack_exports__["default"] = ({
21352136
data: function data() {
21362137
return {
@@ -2150,43 +2151,51 @@ __webpack_require__.r(__webpack_exports__);
21502151
},
21512152
methods: {
21522153
saveStudent: function saveStudent() {
2154+
var _this = this;
2155+
21532156
axios.post("save_student", {
21542157
name: this.name,
21552158
email: this.email,
21562159
phone: this.phone
2160+
}).then(function (response) {
2161+
_this.getResults(); //show list student after add
2162+
21572163
});
21582164
},
21592165
// Our method to GET results from a Laravel endpoint
21602166
getResults: function getResults() {
2161-
var _this = this;
2167+
var _this2 = this;
21622168

21632169
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
21642170
axios.get("all_students/?page=" + page).then(function (response) {
21652171
console.log(response.data);
2166-
_this.students = response.data;
2172+
_this2.students = response.data;
21672173
});
21682174
},
21692175
// create method edit student
21702176
editStudent: function editStudent(id) {
2171-
var _this2 = this;
2177+
var _this3 = this;
21722178

21732179
axios.get("edit_student/" + id).then(function (response) {
21742180
console.log(response.data);
2175-
_this2.id = response.data.id;
2176-
_this2.edit_name = response.data.name;
2177-
_this2.edit_email = response.data.email;
2178-
_this2.edit_phone = response.data.phone;
2181+
_this3.id = response.data.id;
2182+
_this3.edit_name = response.data.name;
2183+
_this3.edit_email = response.data.email;
2184+
_this3.edit_phone = response.data.phone;
21792185
});
21802186
},
21812187
updateStudent: function updateStudent() {
2188+
var _this4 = this;
2189+
21822190
console.log(this.id);
21832191
axios.put("update_student", {
21842192
id: this.id,
21852193
name: this.edit_name,
21862194
email: this.edit_email,
21872195
phone: this.edit_phone
21882196
}).then(function (response) {
2189-
return console.log(response);
2197+
_this4.getResults(); //show list student after update
2198+
21902199
});
21912200
}
21922201
}
@@ -38798,8 +38807,8 @@ var render = function() {
3879838807
_c(
3879938808
"button",
3880038809
{
38801-
staticClass: "btn btn-primary",
38802-
attrs: { type: "button" },
38810+
staticClass: "btn btn-success",
38811+
attrs: { type: "button", "data-dismiss": "modal" },
3880338812
on: {
3880438813
click: function($event) {
3880538814
$event.preventDefault()

resources/js/components/CreateComponent.vue

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@
161161
</button>
162162
<button
163163
type="button"
164+
data-dismiss="modal"
164165
v-on:click.prevent="updateStudent"
165-
class="btn btn-primary"
166+
class="btn btn-success"
166167
>
167168
Save changes
168169
</button>
@@ -196,11 +197,15 @@ export default {
196197
},
197198
methods: {
198199
saveStudent() {
199-
axios.post("save_student", {
200-
name: this.name,
201-
email: this.email,
202-
phone: this.phone,
203-
});
200+
axios
201+
.post("save_student", {
202+
name: this.name,
203+
email: this.email,
204+
phone: this.phone,
205+
})
206+
.then((response) => {
207+
this.getResults(); //show list student after add
208+
});
204209
},
205210
206211
// Our method to GET results from a Laravel endpoint
@@ -229,7 +234,9 @@ export default {
229234
email: this.edit_email,
230235
phone: this.edit_phone,
231236
})
232-
.then((response) => console.log(response));
237+
.then((response) => {
238+
this.getResults(); //show list student after update
239+
});
233240
},
234241
},
235242
};

0 commit comments

Comments
 (0)