Fakultas Ilmu Komputer UI

Commit 9c7d782a authored by aabccd021's avatar aabccd021
Browse files

create user

parent b0627deb
......@@ -30,6 +30,7 @@ class MahasiswaController extends Controller
public function create()
{
//
}
/**
......@@ -40,7 +41,23 @@ class MahasiswaController extends Controller
*/
public function store(Request $request)
{
//
function generateRandomString($length = 10)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$mahasiswa = new Mahasiswa;
$mahasiswa->user_id = $request->user_id;
$mahasiswa->password = generateRandomString();
$mahasiswa->save();
}
/**
......
......@@ -2113,11 +2113,17 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
//
//
//
//
//
/* harmony default export */ __webpack_exports__["default"] = ({
data: function data() {
return {
mahasiswas: [],
mahasiswas_uri: "/admin/resource/mahasiswas"
mahasiswas_uri: "/admin/resource/mahasiswas",
user_id: ""
};
},
methods: {
......@@ -2132,6 +2138,15 @@ __webpack_require__.r(__webpack_exports__);
},
putAsyncData: function putAsyncData(data) {
this.mahasiswas = data;
},
submitForm: function submitForm(e) {
e.preventDefault();
console.log(this.user_id);
axios.post(this.mahasiswas_uri, {
user_id: this.user_id
}).then(function (res) {
return console.log("berhasil");
});
}
},
mounted: function mounted() {
......@@ -20088,7 +20103,36 @@ var render = function() {
0
)
]
)
),
_vm._v(" "),
_c("form", { on: { submit: _vm.submitForm } }, [
_c("strong", [_vm._v("UserID:")]),
_vm._v(" "),
_c("textarea", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.user_id,
expression: "user_id"
}
],
staticClass: "form-control",
domProps: { value: _vm.user_id },
on: {
input: function($event) {
if ($event.target.composing) {
return
}
_vm.user_id = $event.target.value
}
}
}),
_vm._v(" "),
_c("button", { staticClass: "btn btn-success" }, [
_vm._v("Submit")
])
])
])
])
])
......
......@@ -27,6 +27,11 @@
</tr>
</tbody>
</table>
<form @submit="submitForm">
<strong>UserID:</strong>
<textarea class="form-control" v-model="user_id"></textarea>
<button class="btn btn-success">Submit</button>
</form>
</div>
</div>
</div>
......@@ -40,6 +45,7 @@ export default {
return {
mahasiswas: [],
mahasiswas_uri: "/admin/resource/mahasiswas",
user_id: "",
};
},
methods: {
......@@ -53,6 +59,13 @@ export default {
putAsyncData(data) {
this.mahasiswas = data;
},
submitForm(e) {
e.preventDefault();
console.log(this.user_id);
axios
.post(this.mahasiswas_uri, { user_id: this.user_id })
.then((res) => console.log("berhasil"));
},
},
mounted() {
this.loadData();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment