Skip to content

Commit dc4a2fc

Browse files
authored
Merge pull request #3 from TanHongIT/2-edit
2 edit
2 parents d3d068d + 0345826 commit dc4a2fc

File tree

4 files changed

+444
-9
lines changed

4 files changed

+444
-9
lines changed

app/Http/Controllers/StudentController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ public function all_students(){
2020
$students = Student::paginate(5);
2121
return response()->json($students);
2222
}
23+
public function edit_student($id){
24+
$student = Student::find($id);
25+
return response()->json($student);
26+
}
2327
}

public/js/app.js

Lines changed: 326 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,13 +2039,110 @@ __webpack_require__.r(__webpack_exports__);
20392039
//
20402040
//
20412041
//
2042+
//
2043+
//
2044+
//
2045+
//
2046+
//
2047+
//
2048+
//
2049+
//
2050+
//
2051+
//
2052+
//
2053+
//
2054+
//
2055+
//
2056+
//
2057+
//
2058+
//
2059+
//
2060+
//
2061+
//
2062+
//
2063+
//
2064+
//
2065+
//
2066+
//
2067+
//
2068+
//
2069+
//
2070+
//
2071+
//
2072+
//
2073+
//
2074+
//
2075+
//
2076+
//
2077+
//
2078+
//
2079+
//
2080+
//
2081+
//
2082+
//
2083+
//
2084+
//
2085+
//
2086+
//
2087+
//
2088+
//
2089+
//
2090+
//
2091+
//
2092+
//
2093+
//
2094+
//
2095+
//
2096+
//
2097+
//
2098+
//
2099+
//
2100+
//
2101+
//
2102+
//
2103+
//
2104+
//
2105+
//
2106+
//
2107+
//
2108+
//
2109+
//
2110+
//
2111+
//
2112+
//
2113+
//
2114+
//
2115+
//
2116+
//
2117+
//
2118+
//
2119+
//
2120+
//
2121+
//
2122+
//
2123+
//
2124+
//
2125+
//
2126+
//
2127+
//
2128+
//
2129+
//
2130+
//
2131+
//
2132+
//
2133+
//
2134+
//
2135+
//
20422136
/* harmony default export */ __webpack_exports__["default"] = ({
20432137
data: function data() {
20442138
return {
20452139
students: {},
20462140
name: "",
20472141
email: "",
2048-
phone: ""
2142+
phone: "",
2143+
edit_name: "",
2144+
edit_email: "",
2145+
edit_phone: ""
20492146
};
20502147
},
20512148
mounted: function mounted() {
@@ -2066,8 +2163,19 @@ __webpack_require__.r(__webpack_exports__);
20662163

20672164
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
20682165
axios.get("all_students/?page=" + page).then(function (response) {
2166+
console.log(response.data);
20692167
_this.students = response.data;
2168+
});
2169+
},
2170+
// create method edit student
2171+
editStudent: function editStudent(id) {
2172+
var _this2 = this;
2173+
2174+
axios.get("edit_student/" + id).then(function (response) {
20702175
console.log(response.data);
2176+
_this2.edit_name = response.data.name;
2177+
_this2.edit_email = response.data.email;
2178+
_this2.edit_phone = response.data.phone;
20712179
});
20722180
}
20732181
}
@@ -38502,7 +38610,46 @@ var render = function() {
3850238610
_vm._v(" "),
3850338611
_c("td", [_vm._v(_vm._s(student.phone))]),
3850438612
_vm._v(" "),
38505-
_c("td", [_vm._v("Dele")])
38613+
_c("td", [
38614+
_c(
38615+
"button",
38616+
{
38617+
staticClass: "btn btn-primary",
38618+
attrs: {
38619+
type: "button",
38620+
"data-toggle": "modal",
38621+
"data-target": "#exampleModal"
38622+
},
38623+
on: {
38624+
click: function($event) {
38625+
return _vm.editStudent(student.id)
38626+
}
38627+
}
38628+
},
38629+
[
38630+
_vm._v(
38631+
"\n Edit\n "
38632+
)
38633+
]
38634+
),
38635+
_vm._v("\n |\n "),
38636+
_c(
38637+
"button",
38638+
{
38639+
staticClass: "btn btn-primary",
38640+
attrs: {
38641+
type: "button",
38642+
"data-toggle": "modal",
38643+
"data-target": "#exampleModal"
38644+
}
38645+
},
38646+
[
38647+
_vm._v(
38648+
"\n Delete\n "
38649+
)
38650+
]
38651+
)
38652+
])
3850638653
])
3850738654
}),
3850838655
0
@@ -38518,7 +38665,137 @@ var render = function() {
3851838665
)
3851938666
])
3852038667
])
38521-
])
38668+
]),
38669+
_vm._v(" "),
38670+
_c(
38671+
"div",
38672+
{
38673+
staticClass: "modal fade",
38674+
attrs: {
38675+
id: "exampleModal",
38676+
tabindex: "-1",
38677+
role: "dialog",
38678+
"aria-labelledby": "exampleModalLabel",
38679+
"aria-hidden": "true"
38680+
}
38681+
},
38682+
[
38683+
_c(
38684+
"div",
38685+
{ staticClass: "modal-dialog", attrs: { role: "document" } },
38686+
[
38687+
_c("div", { staticClass: "modal-content" }, [
38688+
_vm._m(1),
38689+
_vm._v(" "),
38690+
_c("div", { staticClass: "modal-body" }, [
38691+
_c("form", [
38692+
_c("div", { staticClass: "form-group" }, [
38693+
_c("label", { attrs: { for: "exampleInputEmail1" } }, [
38694+
_vm._v("Name")
38695+
]),
38696+
_vm._v(" "),
38697+
_c("input", {
38698+
directives: [
38699+
{
38700+
name: "model",
38701+
rawName: "v-model",
38702+
value: _vm.edit_name,
38703+
expression: "edit_name"
38704+
}
38705+
],
38706+
staticClass: "form-control",
38707+
attrs: { type: "text", placeholder: "Enter Name" },
38708+
domProps: { value: _vm.edit_name },
38709+
on: {
38710+
input: function($event) {
38711+
if ($event.target.composing) {
38712+
return
38713+
}
38714+
_vm.edit_name = $event.target.value
38715+
}
38716+
}
38717+
})
38718+
]),
38719+
_vm._v(" "),
38720+
_c("div", { staticClass: "form-group" }, [
38721+
_c("label", { attrs: { for: "exampleInputEmail1" } }, [
38722+
_vm._v("Email")
38723+
]),
38724+
_vm._v(" "),
38725+
_c("input", {
38726+
directives: [
38727+
{
38728+
name: "model",
38729+
rawName: "v-model",
38730+
value: _vm.edit_email,
38731+
expression: "edit_email"
38732+
}
38733+
],
38734+
staticClass: "form-control",
38735+
attrs: { type: "email", placeholder: "Enter email" },
38736+
domProps: { value: _vm.edit_email },
38737+
on: {
38738+
input: function($event) {
38739+
if ($event.target.composing) {
38740+
return
38741+
}
38742+
_vm.edit_email = $event.target.value
38743+
}
38744+
}
38745+
})
38746+
]),
38747+
_vm._v(" "),
38748+
_c("div", { staticClass: "form-group" }, [
38749+
_c("label", { attrs: { for: "exampleInputEmail1" } }, [
38750+
_vm._v("Phone")
38751+
]),
38752+
_vm._v(" "),
38753+
_c("input", {
38754+
directives: [
38755+
{
38756+
name: "model",
38757+
rawName: "v-model",
38758+
value: _vm.edit_phone,
38759+
expression: "edit_phone"
38760+
}
38761+
],
38762+
staticClass: "form-control",
38763+
attrs: { type: "phone", placeholder: "Enter Phone" },
38764+
domProps: { value: _vm.edit_phone },
38765+
on: {
38766+
input: function($event) {
38767+
if ($event.target.composing) {
38768+
return
38769+
}
38770+
_vm.edit_phone = $event.target.value
38771+
}
38772+
}
38773+
})
38774+
]),
38775+
_vm._v(" "),
38776+
_c(
38777+
"button",
38778+
{
38779+
staticClass: "btn btn-primary",
38780+
attrs: { type: "submit" },
38781+
on: {
38782+
click: function($event) {
38783+
$event.preventDefault()
38784+
return _vm.saveStudent($event)
38785+
}
38786+
}
38787+
},
38788+
[_vm._v("\n Submit\n ")]
38789+
)
38790+
])
38791+
]),
38792+
_vm._v(" "),
38793+
_vm._m(2)
38794+
])
38795+
]
38796+
)
38797+
]
38798+
)
3852238799
])
3852338800
}
3852438801
var staticRenderFns = [
@@ -38539,6 +38816,52 @@ var staticRenderFns = [
3853938816
_c("th", { attrs: { scope: "col" } }, [_vm._v("Action")])
3854038817
])
3854138818
])
38819+
},
38820+
function() {
38821+
var _vm = this
38822+
var _h = _vm.$createElement
38823+
var _c = _vm._self._c || _h
38824+
return _c("div", { staticClass: "modal-header" }, [
38825+
_c(
38826+
"h5",
38827+
{ staticClass: "modal-title", attrs: { id: "exampleModalLabel" } },
38828+
[_vm._v("Modal title")]
38829+
),
38830+
_vm._v(" "),
38831+
_c(
38832+
"button",
38833+
{
38834+
staticClass: "close",
38835+
attrs: {
38836+
type: "button",
38837+
"data-dismiss": "modal",
38838+
"aria-label": "Close"
38839+
}
38840+
},
38841+
[_c("span", { attrs: { "aria-hidden": "true" } }, [_vm._v("×")])]
38842+
)
38843+
])
38844+
},
38845+
function() {
38846+
var _vm = this
38847+
var _h = _vm.$createElement
38848+
var _c = _vm._self._c || _h
38849+
return _c("div", { staticClass: "modal-footer" }, [
38850+
_c(
38851+
"button",
38852+
{
38853+
staticClass: "btn btn-secondary",
38854+
attrs: { type: "button", "data-dismiss": "modal" }
38855+
},
38856+
[_vm._v("\n Close\n ")]
38857+
),
38858+
_vm._v(" "),
38859+
_c(
38860+
"button",
38861+
{ staticClass: "btn btn-primary", attrs: { type: "button" } },
38862+
[_vm._v("Save changes")]
38863+
)
38864+
])
3854238865
}
3854338866
]
3854438867
render._withStripped = true

0 commit comments

Comments
 (0)