Merge branch 'nisha' into 'main'

update checking taraf masa daftar pengguna

See merge request online-sistem1/lelong!288
This commit is contained in:
Nur Izzati Zulkifli
2022-11-24 08:14:17 +00:00
+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');
}
}