diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index c3ba2a1b5116551989321df86edf65237f0b7a84..e3a65a022eb81f3dd0512a9b021e18239ad79f44 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\AuthenticatesUsers; +use Illuminate\Http\Request; class LoginController extends Controller { @@ -36,4 +37,13 @@ class LoginController extends Controller { $this->middleware('guest')->except('logout'); } + + public function authenticated(Request $request) { + if($request->user()->isPegawaiOnly()){ + return redirect('/pages/profile'); + } + else { + return redirect('/pages'); + } + } } diff --git a/app/User.php b/app/User.php index edc85ff0b325bdb3112e419d1491749b8c0e0632..a5d3db29bb7193bb9d8360a5d6309303dd6f443a 100644 --- a/app/User.php +++ b/app/User.php @@ -5,6 +5,7 @@ namespace App; use App\Notification\ResetPassword; use Illuminate\Notifications\Notifiable; +use Illuminate\Http\Request; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable @@ -36,4 +37,20 @@ class User extends Authenticatable public function sendPasswordResetNotification($token) { $this->notify(new ResetPassword($token)); } + + public function isAdmin() { + return !is_null(Admin::find($this->id)); + } + + public function isPMO() { + return !is_null(PMO::find($this->id)); + } + + public function isPegawai() { + return !is_null(Pegawai::find($this->id)); + } + + public function isPegawaiOnly() { + return ($this->isPegawai() and !$this->isPMO() and !$this->isAdmin()); + } }