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');
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $title = 'Danh sách tài khoản';
     $data = UserModel::all();
     //paginate(5);
     return view('user.index')->with('title', $title)->with('data', $data);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 10; $i++) {
         $user = \App\UserModel::create(['username' => $faker->userName, 'password' => $faker->md5, 'full_name' => $faker->title . ' ' . $faker->name]);
     }
 }
示例#4
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;
     }
 }
 public function update(Request $request)
 {
     $user = UserModel::find($request->get('id_skpd'));
     $user->username = $request->get('username');
     $user->password = $request->get('password');
     $user->save();
     $skpd = SKPDModel::where('id', $request->get('id_skpd'))->first();
     $skpd->nama = $request->get('nama');
     $skpd->alamat = $request->get('alamat');
     $skpd->save();
     DB::table('ppl_citizenreport_penanggungjawab')->where('id_skpd', $request->get('id_skpd'))->update(array('id_kategori' => $request->get('id_kategori')));
     return redirect('manajemen-skpd')->with('message', 'Akun SKPD telah diupdate.');
 }
 /**
  * Providing All user data to the App
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function userData(Request $request)
 {
     $user = UserModel::find($request->session()->get(AppSession::USER_ID));
     $jsonResponse = [APIResponse::REQUEST_STATUS => APIResponse::SUCCESSFUL];
     if ($user != null) {
         $jsonResponse = array_merge($jsonResponse, $user->toArray());
         $idea = $user->idea;
         if ($idea != null) {
             $jsonResponse = array_merge($jsonResponse, $idea->toArray());
             $teamMembers = $idea->teamMembers;
             if ($teamMembers != null) {
                 $teamMemberEmails = [];
                 foreach ($teamMembers as $key => $value) {
                     array_push($teamMemberEmails, $value->team_member_email);
                 }
                 $jsonResponse = array_merge($jsonResponse, ["team_member_emails" => $teamMemberEmails]);
             }
         }
     }
     return response()->json($jsonResponse);
 }
示例#8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     UserModel::find($id)->delete();
     return redirect('home');
 }
示例#9
0
 /**
 * Show all of the users for the application.
 *
 * @return Response
 */
 public function index()
 {
     $users = UserModel::all();
     return $users;
 }
示例#10
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $user = UserModel::find($id);
     $user->delete();
     return Redirect::route('admin.users.index');
 }
 /**
  * Saving additional Details of the idea
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function saveIdeaAdditionalDetails(Request $request)
 {
     $path_for_user = self::STORAGE_FILE_DIRECTORY . "/designs_" . $request->session()->get(AppSession::USER_ID);
     $jsonReply = array_merge([APIResponse::REQUEST_STATUS => APIResponse::SUCCESSFUL], $request->all());
     $files = Input::file("file");
     if (count($files) > 0) {
         foreach ($files as $key => $file) {
             $file->move(public_path() . "/" . $path_for_user, $file->getClientOriginalName());
         }
     }
     $idea = IdeaModel::where('user_id', '=', $request->session()->get(AppSession::USER_ID))->first();
     $idea->additional_information = $request->additional_info;
     $idea->app_designs_link = asset($path_for_user);
     $idea->save();
     $user = UserModel::find($request->session()->get(AppSession::USER_ID));
     $teamMember = $idea->teamMembers;
     Mail::send('email.confirm', [], function ($m) use($user, $teamMember) {
         $m->to($user->email)->subject('Founders Market :: Thanks for Registering form the Competition');
     });
     Mail::send('email.internal.new_registration', ['user' => $user, 'idea' => $idea, 'teamMember' => $teamMember], function ($m) use($user) {
         $m->to("*****@*****.**")->cc("*****@*****.**")->subject('Founders Market :: New user registered for Idea Competition');
     });
 }
示例#12
0
 public function getUserTable()
 {
     $sites = UserModel::all();
     $results = array();
     foreach ($sites as $site) {
         array_push($results, array($site->rank, $site->name));
     }
     return response()->json($results);
 }