update
This commit is contained in:
@@ -67,6 +67,19 @@ class PenggunaController extends Controller
|
||||
->with('success','Tukar Taraf Berjaya');
|
||||
}
|
||||
|
||||
public function delete($userid)
|
||||
{
|
||||
$user = User::where('id','=',$userid)->first();
|
||||
$allrolesuser = $user->getRoleNames();
|
||||
foreach($allrolesuser as $index=>$role)
|
||||
{
|
||||
$user->removeRole($role);
|
||||
}
|
||||
$user->delete();
|
||||
return redirect()->route('pengguna.index')
|
||||
->with('success','Padam Pengguna Berjaya');
|
||||
}
|
||||
|
||||
public function taraf() //taraf = roles in db
|
||||
{
|
||||
$arrayrole = [];
|
||||
@@ -110,6 +123,15 @@ class PenggunaController extends Controller
|
||||
->with('success','Tukar Roles Berjaya');
|
||||
}
|
||||
|
||||
public function deletetaraf($roleid)
|
||||
{
|
||||
$taraf = Role::where('id','=',$roleid)->first();
|
||||
$taraf->delete();
|
||||
|
||||
return redirect()->route('pengguna.taraf')
|
||||
->with('success','Padam Taraf Berjaya');
|
||||
}
|
||||
|
||||
public function roles() //roles = permissions in db
|
||||
{
|
||||
$allpermission = Permission::all();
|
||||
@@ -128,5 +150,13 @@ class PenggunaController extends Controller
|
||||
->with('success','Tukar Roles Berjaya');
|
||||
}
|
||||
|
||||
public function deleterole($roleid)
|
||||
{
|
||||
$role = Permission::where('id','=',$roleid)->first();
|
||||
$role->delete();
|
||||
return redirect()->route('pengguna.roles')
|
||||
->with('success','Padam Roles Berjaya');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class Authenticate extends Middleware
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
return route('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
</div>
|
||||
<ul class="list-unstyled components">
|
||||
<p>Dummy Heading</p>
|
||||
@hasrole('admin')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="{{url('/home')}}">Home </a>
|
||||
</li>
|
||||
@hasrole('admin')
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="{{url('/home')}}">Home </a>
|
||||
</li> --}}
|
||||
<li class="{{ (request()->is('pengguna/*')) ? 'active' : '' }}">
|
||||
<a href="#penggunaSubmenu" data-toggle="collapse" aria-expanded="false" style="">Pengurusan Pengguna</a>
|
||||
<ul class="list-unstyled collapse {{ (request()->is('pengguna/*')) ? 'show' : '' }}" id="penggunaSubmenu" >
|
||||
@@ -36,39 +39,39 @@
|
||||
|
||||
@endhasrole
|
||||
@hasrole('khazanah')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="/home">Home</a>
|
||||
</li>
|
||||
</li> --}}
|
||||
@endhasrole
|
||||
@hasrole('teller')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="/home">Home</a>
|
||||
</li>
|
||||
</li> --}}
|
||||
@endhasrole
|
||||
@hasrole('pengurus-cawangan')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="/home">Home</a>
|
||||
</li>
|
||||
</li> --}}
|
||||
@endhasrole
|
||||
@hasrole('jurulelong')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="/home">Home</a>
|
||||
</li>
|
||||
</li> --}}
|
||||
@endhasrole
|
||||
@hasrole('operasi')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="/home">Home</a>
|
||||
</li>
|
||||
</li> --}}
|
||||
@endhasrole
|
||||
@hasrole('account')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="/home">Home</a>
|
||||
</li>
|
||||
</li> --}}
|
||||
@endhasrole
|
||||
@hasrole('pembida')
|
||||
<li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
{{-- <li class="{{ (request()->is('home')) ? 'active' : '' }}">
|
||||
<a href="/home">Home</a>
|
||||
</li>
|
||||
</li> --}}
|
||||
@endhasrole
|
||||
</ul>
|
||||
{{-- <ul class="list-unstyled CTAs">
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="row ">
|
||||
<div class="col-md-11 mx-auto card p-4">
|
||||
|
||||
@if ($message = Session::get('success'))
|
||||
<div class="alert alert-success">
|
||||
<p>{{ $message }}</p>
|
||||
@@ -44,19 +45,12 @@
|
||||
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ route('pengguna.show',$user->id) }}"><i class="far fa-edit"></i></a>
|
||||
<a href="{{ route('pengguna.show',$user->id) }}"><i class="far fa-eye"></i></a>
|
||||
<a href="{{ route('pengguna.show',$user->id) }}"><i class="far fa-trash-alt"></i></a>
|
||||
{{-- <form action="{{ route('pengguna.updatepengguna',$user->id) }}" method="POST">
|
||||
|
||||
<a class="btn btn-info" href="{{ route('users.show',$user->id) }}">Show</a>
|
||||
|
||||
<a class="btn btn-primary" href="{{ route('users.edit',$user->id) }}">Edit</a>
|
||||
|
||||
<form action="{{ route('pengguna.delete',$user->id) }}" method="POST" id="formdelpengguna-{{$user->id}}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
|
||||
<button type="submit" class="btn btn-danger">Delete</button> --}}
|
||||
{{-- <input type="userid" value="{{$user->id}}"> --}}
|
||||
<a href="{{ route('pengguna.show',$user->id) }}"><i class="far fa-edit"></i></a>
|
||||
<a href="{{ route('pengguna.show',$user->id) }}"><i class="far fa-eye"></i></a>
|
||||
<a onclick="confirm({{$user->id}})"><i class="far fa-trash-alt"></i></a>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -69,6 +63,28 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function confirm(id) {
|
||||
// console.log(id);
|
||||
$.confirm({
|
||||
title: 'Confirmation',
|
||||
content: 'Anda pasti?',
|
||||
type: 'orange',
|
||||
typeAnimated: true,
|
||||
buttons: {
|
||||
Delete: {
|
||||
btnClass: 'btn-warning',
|
||||
action: function () {
|
||||
$("#formdelpengguna-"+id).submit();
|
||||
}
|
||||
},
|
||||
Batal: {
|
||||
btnClass: 'btn-default',
|
||||
action: function () {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready( function () {
|
||||
table = $('#pengguna').DataTable( {
|
||||
"columnDefs": [
|
||||
@@ -93,7 +109,7 @@
|
||||
{
|
||||
className: 'btn btn-outline-success pl-4 pr-4 btn-sm adduser',
|
||||
text: '<i class="fas fa-plus" id="test"></i>',
|
||||
titleAttr: 'Add User',
|
||||
titleAttr: 'Tambah Pengguna',
|
||||
action: function ( e, dt, node, config ) {
|
||||
alert( 'Button activated' );
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@section('content')
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-11 mx-auto card p-4">
|
||||
<div class="col-md-5 mx-auto card p-4">
|
||||
@if ($message = Session::get('success'))
|
||||
<div class="alert alert-success">
|
||||
<p>{{ $message }}</p>
|
||||
@@ -25,11 +25,14 @@
|
||||
<td>{{ $role->name }}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-edit"></i></a>
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-eye"></i></a>
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-trash-alt"></i></a>
|
||||
{{-- <a class="btn btn-info" href="{{ route('pengguna.showtaraf',$role->id) }}">Edit</a> --}}
|
||||
<form action="{{ route('pengguna.deleterole',$role->id) }}" method="POST" id="formdelrole-{{$role->id}}">
|
||||
@csrf
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-edit"></i></a>
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-eye"></i></a>
|
||||
<a onclick="confirm({{$role->id}})"><i class="far fa-trash-alt"></i></a>
|
||||
</form>
|
||||
{{-- <a class="btn btn-info" href="{{ route('pengguna.showtaraf',$role->id) }}">Edit</a> --}}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@@ -41,6 +44,27 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function confirm(id) {
|
||||
// console.log(id);
|
||||
$.confirm({
|
||||
title: 'Confirmation',
|
||||
content: 'Anda pasti?',
|
||||
type: 'orange',
|
||||
typeAnimated: true,
|
||||
buttons: {
|
||||
Delete: {
|
||||
btnClass: 'btn-warning',
|
||||
action: function () {
|
||||
$("#formdelrole-"+id).submit();
|
||||
}
|
||||
},
|
||||
Batal: {
|
||||
btnClass: 'btn-default',
|
||||
action: function () {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).ready( function () {
|
||||
$('#roles').DataTable({
|
||||
"columnDefs": [
|
||||
@@ -62,7 +86,7 @@
|
||||
{
|
||||
className: 'btn btn-outline-success pl-4 pr-4 btn-sm adduser',
|
||||
text: '<i class="fas fa-plus" id="test"></i>',
|
||||
titleAttr: 'Add User',
|
||||
titleAttr: 'Tambah Role',
|
||||
action: function ( e, dt, node, config ) {
|
||||
alert( 'Button activated' );
|
||||
}
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
@endforeach
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{-- <i class="far fa-edit"></i> --}}
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-edit"></i></a>
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-eye"></i></a>
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-trash-alt"></i></a>
|
||||
|
||||
<form action="{{ route('pengguna.deletetaraf',$role->id) }}" method="POST" id="formdeltaraf-{{$role->id}}">
|
||||
@csrf
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-edit"></i></a>
|
||||
<a href="{{ route('pengguna.showtaraf',$role->id) }}"><i class="far fa-eye"></i></a>
|
||||
<a onclick="confirm({{$role->id}})"><i class="far fa-trash-alt"></i></a>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@@ -46,6 +47,27 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function confirm(id) {
|
||||
// console.log(id);
|
||||
$.confirm({
|
||||
title: 'Confirmation',
|
||||
content: 'Anda pasti?',
|
||||
type: 'orange',
|
||||
typeAnimated: true,
|
||||
buttons: {
|
||||
Delete: {
|
||||
btnClass: 'btn-warning',
|
||||
action: function () {
|
||||
$("#formdeltaraf-"+id).submit();
|
||||
}
|
||||
},
|
||||
Batal: {
|
||||
btnClass: 'btn-default',
|
||||
action: function () {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).ready( function () {
|
||||
$('#taraf').DataTable({
|
||||
"columnDefs": [
|
||||
@@ -70,7 +92,7 @@
|
||||
{
|
||||
className: 'btn btn-outline-success pl-4 pr-4 btn-sm adduser',
|
||||
text: '<i class="fas fa-plus" id="test"></i>',
|
||||
titleAttr: 'Add User',
|
||||
titleAttr: 'Tambah Taraf',
|
||||
action: function ( e, dt, node, config ) {
|
||||
alert( 'Button activated' );
|
||||
}
|
||||
|
||||
+6
-2
@@ -29,12 +29,16 @@ Route::group(['middleware' => ['permission:pengguna'],'prefix'=>'pengguna'], fun
|
||||
Route::get('/listpengguna',['as'=>'pengguna.index','uses'=>'PenggunaController@index']);
|
||||
Route::get('/listpengguna/{userid}',['as'=>'pengguna.show','uses'=>'PenggunaController@show']);
|
||||
Route::post('/store',['as'=>'pengguna.store','uses'=>'PenggunaController@store']);
|
||||
Route::post('/delete/{userid}',['as'=>'pengguna.delete','uses'=>'PenggunaController@delete']);
|
||||
|
||||
Route::get('/taraf',['as'=>'pengguna.taraf','uses'=>'PenggunaController@taraf']);
|
||||
Route::get('/taraf/{tarafid}',['as'=>'pengguna.showtaraf','uses'=>'PenggunaController@showtaraf']);
|
||||
Route::post('/storetaraf',['as'=>'pengguna.storetaraf','uses'=>'PenggunaController@storetaraf']);
|
||||
|
||||
Route::get('/roles','PenggunaController@roles');
|
||||
Route::post('/deletetaraf/{roleid}',['as'=>'pengguna.deletetaraf','uses'=>'PenggunaController@deletetaraf']);
|
||||
|
||||
// Route::get('/roles','PenggunaController@roles');
|
||||
Route::get('/roles',['as'=>'pengguna.roles','uses'=>'PenggunaController@roles']);
|
||||
Route::post('/deleterole/{roleid}',['as'=>'pengguna.deleterole','uses'=>'PenggunaController@deleterole']);
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user