public function postTaoTaiKhoanNhanVienTruong(TaiKhoanNhanVienTruongRequest $request)
 {
     // thêm vào bảng users
     $user = new User();
     $user->username = $request->txtUsername;
     $user->name = $request->txtName;
     $user->password = Hash::make($request->txtPassword);
     $user->save();
     // thêm vào bảng permission_user
     $permission = Permission::where('slug', 'universitystaff')->get()->first();
     $permissionUser = new PermissionUser();
     $permissionUser->permission_id = $permission->id;
     $permissionUser->user_id = $user->id;
     $permissionUser->save();
     // thêm trường
     $truong = new Truong();
     $truong->tentr = $request->txtUniversity;
     $truong->matr = $request->txtUniversityCode;
     $truong->nhanvienquanly_user_id = $user->id;
     $truong->save();
     return redirect()->action('ClusterStaffManagerController@getTaoTaiKhoanNhanVienTruong')->with(['flash_level' => 'success', 'flash_message' => 'Thêm tài khoản thành công!']);
 }
예제 #2
0
 public function deleteMajor($id)
 {
     $nganhs = Nganh::find($id);
     if ($nganhs == null) {
         return redirect()->action('UniversityStaffController@getListMajor');
     }
     $truong_id = $nganhs->first()->truong_id;
     $truongs = Truong::find($truong_id);
     if ($truongs == null) {
         return redirect()->action('UniversityStaffController@getListMajor');
     }
     $nhanvientruong_id = $truongs->first()->nhanvienquanly_user_id;
     if ($nhanvientruong_id != Auth::user()->id) {
         return redirect()->action('UniversityStaffController@getListMajor');
     }
     $nganhs->delete();
     return redirect()->action('UniversityStaffController@getListMajor');
 }
예제 #3
0
 public function postTimTruong()
 {
     $keyword = Input::get('keyword');
     $truongs = Truong::select('id', 'tentr', 'matr')->where('tentr', 'LIKE', '%' . $keyword . '%')->orWhere('matr', 'LIKE', '%' . $keyword . '%')->get()->toArray();
     return json_encode($truongs);
 }