update checking taraf

This commit is contained in:
nishaMuhd
2022-11-24 16:12:21 +08:00
parent 6d1b9bbbab
commit 2de49a7038
+21 -11
View File
@@ -91,6 +91,22 @@ class PenggunaController extends Controller
{
return redirect()->route('pengguna.index')->with('failed','Maaf, Nama Pengguna / Emel Berikut Telah Wujud !');
} else {
$allroles = Role::all()->pluck('name');
$arraytaraf = [];
$counttaraf = 0;
foreach($allroles as $index=>$taraf) {
$req = 'taraf'.$taraf;
if($request->$req)
{
$counttaraf++;
array_push($arraytaraf,$taraf);
}
}
if($counttaraf < 1){
return redirect()->route('pengguna.index')->with('failed','Maaf, Taraf Tidak Dipilih');
}
$user = new User;
$user->name = $request->name;
$user->username = $request->username;
@@ -103,18 +119,12 @@ class PenggunaController extends Controller
$user->user_type = 1;
$user->save();
$allroles = Role::all()->pluck('name');
$arraytaraf = [];
foreach($allroles as $index=>$taraf) {
$req = 'taraf'.$taraf;
if($request->$req)
{
array_push($arraytaraf,$taraf);
}
}
$user->syncRoles($arraytaraf);
return redirect()->route('pengguna.index')
->with('success', 'Pengguna Berjaya Disimpan');
return redirect()->route('pengguna.index')
->with('success', 'Pengguna Berjaya Disimpan');
}
}