Пример #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (\Config::get('group') > 0) {
         $user = user::select('musers.*', 'mgroup.groupname')->leftJoin('mgroup', 'mgroup.groupid', '=', 'musers.groupid')->where('musers.status', '>', 0)->where('musers.groupid', '>', 0)->paginate(\Config::get('pages'));
     } else {
         $user = user::where('status', '>', 0)->paginate(\Config::get('pages'));
     }
     return view('admin.master.user.user')->with('users', $user);
 }
Пример #2
0
 public function postLogin(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'password' => 'required']);
     $credentials = $request->only('name', 'password');
     try {
         $user = user::where('name', '=', $credentials['name'])->firstOrFail();
     } catch (ModelNotFoundException $e) {
         return redirect('/')->withInput($request->only('name', 'remember'))->withErrors(['name' => 'These credentials do not match our records.']);
     }
     if ($user) {
         session()->regenerate();
         Session::set('user', $user);
         $group = group::find($user->groupid);
         if ($group->count()) {
             Session::set('group', $group);
             $privileges = privileges_group::select('p.privilegesid as id', 'p.privilegesname as name', 'p.privilegesdesc as desc')->leftJoin('mprivileges as p', 'p.privilegesid', '=', 'mprivileges_group.privilegesid')->where('mprivileges_group.groupid', '=', $group->groupid)->get();
             Session::set('privileges', $privileges);
         }
     }
     if ($this->auth->attempt($credentials, $request->has('remember'))) {
         return redirect('/admin');
     }
     return redirect('/')->withInput($request->only('name', 'remember'))->withErrors(['password' => 'Password is wrong']);
 }
Пример #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $user = user::where('groupid', '=', $id);
     if ($user->count()) {
         $errors[] = 'maaf, group ini dipakai oleh beberapa group, jika anda yakin, mohon hapus user yang terkait dengan group ini';
         return redirect()->back()->withErrors($errors);
     }
     $group = group::find($id);
     $groupchild = group::where('parent', '=', $id);
     if ($groupchild->count()) {
         $errors[] = 'maaf, group ini memiliki sub group!';
         return redirect()->back()->withErrors($errors);
     }
     //Clear permission for this group
     \DB::table('mprivileges_group')->where('groupid', '=', $id)->delete();
     $group->delete();
     return redirect('/admin/group');
 }