public function login(Request $request)
 {
     $nik = $request->get('nik');
     $password = $request->get('password');
     $user = UserModel::where('nik', $nik)->where('password', $password)->first();
     $user_role = strtoupper($user->role);
     if ($user_role == "MASYARAKAT") {
         $daftar_pengaduan = Pengaduan::where('id_masyarakat', $user->id)->where('id_status', 6)->get();
         // status rejected
     } else {
         if ($user_role == "SKPD") {
             $SKPD = PenanggungJawab::where('id_skpd', $user->id)->first();
             $daftar_pengaduan = Pengaduan::where('id_kategori', $SKPD->id_kategori)->where('id_status', 2)->get();
             // status forwarded
         } else {
             $daftar_pengaduan = "";
         }
     }
     if (count($user) < 1) {
         return redirect('login');
     } else {
         Session::put('id_user', $user->id);
         Session::put('username', $user->username);
         Session::put('role', $user_role);
         if ($user_role != "ADMIN" && $daftar_pengaduan != "[]") {
             Session::flash('notification', $daftar_pengaduan);
         }
         return redirect('index');
     }
 }
示例#2
0
 public function post_reset_pass(ResetPass $request)
 {
     $user = UserModel::where('username', $request->username)->first();
     $user->password = Hash::make($request->password);
     $user->forgotpass = '';
     $user->save();
     return redirect()->route('home')->with('success', 'Thay đổi mật khẩu thành công');
 }
 public function getIsSkpdAttribute()
 {
     $role = UserModel::where('id', $this->attributes['id_komentator'])->first()['role'];
     if (strtoupper($role) == "SKPD") {
         return true;
     } else {
         return false;
     }
 }