diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index b9c59aa..31d011b 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -137,7 +137,7 @@ class ProfileController extends Controller 'password.regex' => 'Format Kata Sandi harus mengandung minimal Huruf Besar, Huruf Kecil, Angka, Spesial Karakter', ])->validate(); - $profile = Profile::where('npsn',auth()->user()->username)->first(); + $profile = Profile::where('npsn',auth()->user()->profile->npsn)->first(); $profile->alamat_sekolah = $request->alamat_sekolah; $profile->kontak_person = $request->kontak_person; $profile->telp = $request->telp; diff --git a/app/Http/Middleware/Profile.php b/app/Http/Middleware/Profile.php index a9e6fb8..a5ad8d8 100644 --- a/app/Http/Middleware/Profile.php +++ b/app/Http/Middleware/Profile.php @@ -7,7 +7,6 @@ use Illuminate\Http\Request; use Symfony\Component\HttpFoundation\Response; use Auth; use App\Models\User; -use App\Models\Master\Sekolah; class Profile { @@ -18,9 +17,9 @@ class Profile */ public function handle(Request $request, Closure $next): Response { - $user = Sekolah::where('npsn',auth()->user()->username)->first(); - if(!@$user && (auth()->user()->ms_group_id == 2)){ - return redirect('profile-sekolah/lengkapi/'.encode_id(auth()->user()->username)); + $user = User::with(['profile'])->where('id',auth()->user()->id)->first(); + if(!@$user->profile && ($user->ms_group_id == 2)){ + return redirect('profile-sekolah/lengkapi/'.encode_id($user->username)); } return $next($request); }