public function LuuThemSV(Request $req) { $post = $req->all(); $v = \Validator::make($req->all(), ['txtMaSV' => 'required', 'txtHoTen' => 'required', 'rdGioiTinh' => 'required', 'txtNgaySinh' => 'required|date', 'txtEmail' => 'required|email', 'txtKhoaHoc' => 'required', 'rdNhomHP' => 'required', 'txtMatKhau1' => 'required|min:6', 'txtMatKhau2' => 'required|min:6|same:txtMatKhau1']); if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); } else { // $data = array( // 'mssv' => $_POST['txtMaSV'], // 'hoten' => $_POST['txtHoTen'], // 'gioitinh' => $_POST['rdGioiTinh'], // 'ngaysinh' => $_POST['txtNgaySinh'], // 'email' => $_POST['txtEmail'], // 'khoahoc' => $_POST['txtKhoaHoc'], // 'matkhau' => Hash::make($_POST['txtMatKhau1']), // 'ngaytao' => Carbon::now() // ); // $ch = DB::table('sinh_vien')->insert($data); //Thêm thông tin sinh viên vào bảng sinh_vien $sv = new Sinhvien(); $sv->mssv = $req->txtMaSV; $sv->hoten = $req->txtHoTen; $sv->gioitinh = $req->rdGioiTinh; $sv->ngaysinh = $req->txtNgaySinh; $sv->email = $req->txtEmail; $sv->sdt = $req->txtSDT; $sv->matkhau = Hash::make($req->txtMatKhau1); $sv->nguoitao = \Auth::user()->name; $sv->ngaytao = Carbon::now(); $sv->save(); //Thêm macb, hoten, email, matkhau vào bảng Users $thanhvien = new User(); $thanhvien->taikhoan = $req->txtMaSV; $thanhvien->name = $req->txtHoTen; $thanhvien->email = $req->txtEmail; $thanhvien->password = Hash::make($req->txtMatKhau1); $thanhvien->quyen = 'sv'; $thanhvien->remember_token = $req->_token; $thanhvien->save(); $ch2 = DB::table('chia_nhom')->insert(['mssv' => $_POST['txtMaSV'], 'manhomhp' => $_POST['rdNhomHP'], 'manhomthuchien' => "", 'nhomtruong' => 0]); return redirect('quantri/sinhvien'); } }
public function CapNhatKyNang() { $mssv = \Auth::user()->taikhoan; $sinhvien = Sinhvien::find($mssv); return view('sinhvien.cap-nhat-thong-tin-ky-nang')->with('sv', $sinhvien); }