update checking taraf
This commit is contained in:
@@ -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');
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user