public function ThongTinGV()
 {
     $macb = \Auth::user()->taikhoan;
     $giangvien = Giangvien::find($macb);
     //Lấy năm học và học kỳ hiện tại
     $nam = DB::table('nien_khoa')->distinct()->orderBy('nam', 'desc')->value('nam');
     $hk = DB::table('nien_khoa')->distinct()->orderBy('hocky', 'desc')->where('nam', $nam)->value('hocky');
     $mank = DB::table('nien_khoa as nk')->join('nhom_hocphan as hp', 'nk.mank', '=', 'hp.mank')->where('nk.nam', $nam)->where('nk.hocky', $hk)->value('nk.mank');
     //Lấy ds nhóm học phần GV này phụ trách giảng dạy
     $nhomhp = DB::table('nhom_hocphan as hp')->select('hp.manhomhp', 'hp.tennhomhp')->join('nien_khoa as nk', 'hp.mank', '=', 'nk.mank')->where('nk.mank', $mank)->where('hp.macb', $macb)->get();
     return view('giangvien.thong-tin-giang-vien')->with('gv', $giangvien)->with('nhomhp', $nhomhp)->with('nam', $nam)->with('hk', $hk);
 }
 public function LuuThemGV(Request $req)
 {
     $post = $req->all();
     $v = \Validator::make($req->all(), ['txtMaCB' => 'required', 'txtHoTen' => 'required|max:255', 'rdGioiTinh' => 'required', 'txtNgaySinh' => 'required|date', 'txtEmail' => 'required|email|max:255', 'chkNhomHP' => 'required', 'txtMatKhau1' => 'required|min:6', 'txtMatKhau2' => 'required|min:6|same:txtMatKhau1']);
     if ($v->fails()) {
         return redirect()->back()->withErrors($v->errors());
     } else {
         //            $data1 = array(
         //                    'macb'      => $req->txtMaCB,
         //                    'hoten'     => $req->txtHoTen,
         //                    'gioitinh'  => $req->rdGioiTinh,
         //                    'ngaysinh'  => $req->txtNgaySinh,
         //                    'email'     => $req->txtEmail,
         //                    'sdt'       => $req->txtSDT,
         //                    'matkhau'   => Hash::make($req->txtMatKhau1),
         //                    'ngaytao'   => Carbon::now()
         //            );
         //            $ch1 = DB::table('giang_vien')->insert($data1);
         $gv = new Giangvien();
         $gv->macb = $req->txtMaCB;
         $gv->hoten = $req->txtHoTen;
         $gv->gioitinh = $req->rdGioiTinh;
         $gv->ngaysinh = $req->txtNgaySinh;
         $gv->email = $req->txtEmail;
         $gv->sdt = $req->txtSDT;
         $gv->matkhau = Hash::make($req->txtMatKhau1);
         $gv->nguoitao = \Auth::user()->name;
         $gv->ngaytao = Carbon::now();
         $gv->save();
         //Thêm macb, hoten, email, matkhau vào bảng Users
         $thanhvien = new User();
         $thanhvien->taikhoan = $req->txtMaCB;
         $thanhvien->name = $req->txtHoTen;
         $thanhvien->email = $req->txtEmail;
         $thanhvien->password = Hash::make($req->txtMatKhau1);
         $thanhvien->quyen = 'gv';
         $thanhvien->remember_token = $req->_token;
         $thanhvien->save();
         //Lấy mảng manhomhp khi đã chon checkbox
         $nhomhp_checked = Input::get('chkNhomHP');
         $ch2 = DB::table('nhom_hocphan')->whereIn('manhomhp', $nhomhp_checked)->update(['macb' => $_POST['txtMaCB']]);
         return redirect('quantri/giangvien');
     }
 }