main-gitea-akuncoa
Zelda Ababil 2024-02-01 13:04:06 +07:00
parent 2724413e20
commit 78e6e30a60
7 changed files with 273 additions and 300 deletions

View File

@ -29,7 +29,7 @@ class RoleController extends Controller
// call table user with pagination
$datas = Role::latest()->paginate(10);
return view('pages.admins.roles.index', compact('datas'));
return view('pages.admin.roles.index', compact('datas'));
}
/**
@ -38,7 +38,7 @@ class RoleController extends Controller
public function create()
{
$permissions = Permission::all()->groupBy('group_name');
return view('pages.admins.roles.create', compact('permissions'));
return view('pages.admin.roles.create', compact('permissions'));
}
/**
@ -48,36 +48,28 @@ class RoleController extends Controller
{
// validation
$rules = array(
'name' => 'required',
'email' => 'required|email',
'password' => 'required|min:8'
'name' => 'required|unique:roles',
'permission' => 'required|min:8',
);
$validator = Validator::make($request->all(), $rules);
// check validation
if ($validator->fails()) {
return Redirect::to('admin/roles/create')
return Redirect::to('roles/create')
->withErrors($validator)
->withInput($request->except('password'));
} else {
// create new account
$user = Role::create([
'name' => $request->name,
'email' => $request->email,
'password' => bcrypt($request->password),
]);
// Create role for user
$role = Role::findOrFail($request->role); // Pengunjung
$user->assignRole($role);
$role = Role::create(['name' => $request->input('name')]);
$role->syncPermissions($request->get('permission'));
// Create Session message
Session::flash('roles-message', [
'type' => 'success',
'msg' => 'Anda berhasil menambahkan data!'
'msg' => 'Berhasil menambah data!'
]);
return Redirect::to('admin/roles');
return Redirect::to('roles');
}
}
@ -100,7 +92,7 @@ class RoleController extends Controller
$permissions = Permission::get()->groupBy('group_name');
// call view pages
return view('pages.admins.roles.edit', compact('role', 'permissions', 'rolePermissions'));
return view('pages.admin.roles.edit', compact('role', 'permissions', 'rolePermissions'));
}
/**
@ -110,14 +102,14 @@ class RoleController extends Controller
{
// validation
$rules = array(
'name' => 'required|min:5',
'name' => 'required|unique:roles,name,' . $id . ',id',
'permission' => 'required|min:8',
);
$validator = Validator::make($request->all(), $rules);
// process the login
if ($validator->fails()) {
return Redirect::to('admin/roles/edit/' . $id)
return Redirect::to('roles/edit/' . $id)
->withErrors($validator)
->withInput();
} else {
@ -129,10 +121,10 @@ class RoleController extends Controller
// Create Session message
Session::flash('roles-message', [
'type' => 'success',
'msg' => 'Anda berhasil mengubah data!'
'msg' => 'Berhasil mengubah data!'
]);
return Redirect::to('admin/roles');
return Redirect::to('roles');
}
}

View File

@ -42,8 +42,8 @@ class UserController extends Controller
})
->addColumn('action', function ($users) {
return '
<button class="btn btn-sm btn-warning btn-edit-user" data-id=' . $users->id . '><i class="fas fa-edit"></i></button>
<button class="btn btn-sm btn-danger btn-hapus-user" data-id=' . $users->id . '><i class="fas fa-trash"></i></button>
<button class="btn btn-sm btn-warning btn-edit-user" data-user=' . $users . '><i class="fas fa-edit"></i></button>
<button class="btn btn-sm btn-danger btn-hapus-user" data-user=' . $users . '><i class="fas fa-trash"></i></button>
';
})
->addColumn('updated_atnya', function ($users) {
@ -130,45 +130,54 @@ class UserController extends Controller
public function update(Request $request, string $id)
{
// validation
$rules = array(
'name' => 'required|min:5',
'password' => 'required|min:8',
);
$validator = Validator::make($request->all(), $rules);
$validator = Validator::make($request->all(), [
'name_edit' => 'required',
'email_edit' => 'required|email|unique:users,email,' . $id,
'role_id_edit' => 'required'
], [
'name_edit.required' => 'Nama tidak boleh kosong!',
'email_edit.required' => 'Email tidak boleh kosong!',
'email_edit.email' => 'Email tidak valid!',
'email_edit.unique' => 'Email sudah terdaftar!',
'role_id.required' => 'Role tidak boleh kosong!',
]);
// process the login
// check validation
if ($validator->fails()) {
return Redirect::to('admin/users/edit/' . $id)
->withErrors($validator)
->withInput($request->except('password'));
} else {
return ResponseFormatter::error($validator->errors()->first());
}
try {
DB::beginTransaction();
// create new account
$user = User::findOrFail($id);
if (!$user) {
// Create Session message
Session::flash('users-message', [
'type' => 'warning',
'msg' => 'Data pengguna tidak ditemukan!'
]);
return Redirect::to('admin/users');
}
$user->update([
'name' => $request->name,
'password' => bcrypt($request->password),
'name' => $request->name_edit,
'email' => $request->email_edit,
]);
// Update role for user
$user->removeRole($user->roles[0]->name);
$user->assignRole($request->role);
// Password change
if ($request->password_edit) {
$user->update([
'password' => bcrypt($request->password_edit),
]);
}
// Create Session message
Session::flash('users-message', [
'type' => 'success',
'msg' => 'Anda berhasil mengubah data!'
]);
// Delete role for user
$user->roles()->detach();
return Redirect::to('admin/users');
// Assing role for user
foreach ($request->role_id_edit as $key => $value) {
$role = Role::findOrFail($value); // Pengunjung
$user->assignRole($role);
}
DB::commit();
return ResponseFormatter::success($user, "User berhasil diubah");
} catch (\Throwable $th) {
DB::rollBack();
return ResponseFormatter::error($th->getMessage());
}
}
@ -177,29 +186,17 @@ class UserController extends Controller
*/
public function destroy(string $id)
{
// get data from role
$role = Role::findOrFail($id);
// get data from user
$user = User::findOrFail($id);
// check role
if (!$role) {
// Create Session message
Session::flash('roles-message', [
'type' => 'warning',
'msg' => 'Data pengguna tidak ditemukan!'
]);
return Redirect::to('admin/roles');
// check user
if (!$user) {
return ResponseFormatter::error("Data pengguna tidak ditemukan!");
}
// delete role
$role->delete();
// delete user
$user->delete();
// Create Session message
Session::flash('roles-message', [
'type' => 'success',
'msg' => 'Anda berhasil menghapus data!'
]);
return Redirect::to('admin/roles');
return ResponseFormatter::success(null, "User berhasil dihapus!");
}
}

View File

@ -36,6 +36,7 @@
@can('users.index', auth()->user())
<li class="dropdown-divider"></li>
<li><a href="{{ route('users.index') }}" class="dropdown-item">Setting User</a></li>
<li><a href="{{ route('roles.index') }}" class="dropdown-item">Setting Role</a></li>
@endcan
</ul>
</li>

View File

@ -1,36 +1,38 @@
@extends('layouts.app')
@section('title', 'Tambah Roles Akses')
@section('content')
<!-- Breadcrumb -->
<div class="card bg-info-subtle shadow-none position-relative overflow-hidden mb-4">
<div class="card-body px-4 py-3">
<div class="row align-items-center">
<div class="col-9">
<h4 class="fw-semibold mb-8">Tambah Roles & Permission</h4>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item" aria-current="page">
<a href="{{ URL::to('admin/roles') }}" class="badge text-bg-light text-primary">
Kembali ke halaman sebelumnya
</a>
</li>
</ol>
</nav>
@extends('layouts.base')
@section('content-header')
<div class="col-12">
<div class="container" style="display: contents">
<div class="row mb-2">
<div class="col-sm-6">
<h3 class="m-0"> Master Data</h3>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item"><a href="#">Admin</a></li>
<li class="breadcrumb-item active">Tambah Roles</li>
</ol>
</div>
</div>
</div>
</div>
<!-- End Breadcrumb -->
@endsection
<div class="row d-flex align-items-strech">
<div class="col-lg-12 mx-auto">
@section('content')
<div class="col-lg-12 col-md-12 col-sm-12 mt-2">
<div class="container" style="display: contents">
<div class="card">
<div class="card-header d-flex align-items-center">
<h4 class="card-title mb-0">Tambah Pengguna</h4>
<div class="card-actions cursor-pointer ms-auto d-flex button-group">
<a href="{{ route('roles.refresh-routes') }}" class="btn btn-sm btn-secondary">
<i class="ti ti-refresh"></i>&nbsp; refresh routes
</a>
<div class="card bg-warning" style="min-height:5px; border-radius:1px;"></div>
<div class="card-header mt-0 pt-0">
<div class="d-flex">
<h4>Tambah Role</h4>
<!-- Button trigger modal -->
<div class="ml-auto">
<button type="button" class="btn btn-warning" href="{{ route('roles.refresh-routes') }}">
Refresh Role
</button>
</div>
</div>
</div>
<div class="card-body border-top">
@ -55,10 +57,13 @@
<input type="text" class="form-control" placeholder="Role Name" name="name">
</div>
</div>
<h5 for="permissions" class="form-label mt-3 mb-3">Assign Permissions</h5>
<h6 for="permissions" class="form-label mt-3 mb-3">Check All Permission <input type="checkbox"
name="all_permission" class="check" id="allpermission"></h6>
<span>
<h5 for="permissions" class="form-label mt-3 mb-3">Assign Permissions
</h5>
<h6 for="permissions" class="form-label mt-3 mb-3">Check All Permission
<input type="checkbox" name="all_permission" class="check" id="allpermission">
</h6>
</span>
<div class="row">
@foreach ($permissions as $key => $permission)
<div class="col-md-4">
@ -102,8 +107,7 @@
</div>
</div>
</div>
@stop
@endsection
@push('scripts')
<script>
$('input[type="checkbox"].check').on('change', function() {

View File

@ -1,36 +1,38 @@
@extends('layouts.app')
@section('title', 'Edit Roles Akses')
@section('content')
<!-- Breadcrumb -->
<div class="card bg-info-subtle shadow-none position-relative overflow-hidden mb-4">
<div class="card-body px-4 py-3">
<div class="row align-items-center">
<div class="col-9">
<h4 class="fw-semibold mb-8">Edit Roles & Permission</h4>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item" aria-current="page">
<a href="{{ URL::to('admin/roles') }}" class="badge text-bg-light text-primary">
Kembali ke halaman sebelumnya
</a>
</li>
</ol>
</nav>
@extends('layouts.base')
@section('content-header')
<div class="col-12">
<div class="container" style="display: contents">
<div class="row mb-2">
<div class="col-sm-6">
<h3 class="m-0"> Master Data</h3>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item"><a href="#">Admin</a></li>
<li class="breadcrumb-item active">Edit Roles</li>
</ol>
</div>
</div>
</div>
</div>
<!-- End Breadcrumb -->
@endsection
<div class="row d-flex align-items-strech">
<div class="col-lg-12 mx-auto">
@section('content')
<div class="col-lg-12 col-md-12 col-sm-12 mt-2">
<div class="container" style="display: contents">
<div class="card">
<div class="card-header d-flex align-items-center">
<h4 class="card-title mb-0">Edit Pengguna</h4>
<div class="card-actions cursor-pointer ms-auto d-flex button-group">
<a href="{{ route('roles.refresh-routes') }}" class="btn btn-sm btn-secondary">
<i class="ti ti-refresh"></i>&nbsp; refresh routes
</a>
<div class="card bg-warning" style="min-height:5px; border-radius:1px;"></div>
<div class="card-header mt-0 pt-0">
<div class="d-flex">
<h4>Edit Role</h4>
<!-- Button trigger modal -->
<div class="ml-auto">
<button type="button" class="btn btn-warning" href="{{ route('roles.refresh-routes') }}">
Refresh Role
</button>
</div>
</div>
</div>
<div class="card-body border-top">
@ -56,10 +58,13 @@
value="{{ $role->name }}">
</div>
</div>
<h5 for="permissions" class="form-label mt-3 mb-3">Assign Permissions</h5>
<h6 for="permissions" class="form-label mt-3 mb-3">Check All Permission <input type="checkbox"
name="all_permission" class="check" id="allpermission"></h6>
<span>
<h5 for="permissions" class="form-label mt-3 mb-3">Assign Permissions
</h5>
<h6 for="permissions" class="form-label mt-3 mb-3">Check All Permission
<input type="checkbox" name="all_permission" class="check" id="allpermission">
</h6>
</span>
<div class="row">
@foreach ($permissions as $key => $permission)
<div class="col-md-4">
@ -105,7 +110,7 @@
</div>
</div>
</div>
@stop
@endsection
@push('scripts')
<script>

View File

@ -1,54 +1,48 @@
@extends('layouts.app')
@section('title', 'Hak Akses Pengguna')
@section('content')
<!-- Breadcrumb -->
<div class="card bg-info-subtle shadow-none position-relative overflow-hidden mb-4">
<div class="card-body px-4 py-3">
<div class="row align-items-center">
<div class="col-9">
<h4 class="fw-semibold mb-8">Hak Akes Pengguna</h4>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a class="text-muted text-decoration-none" href="./index.html">User Management</a>
</li>
<li class="breadcrumb-item" aria-current="page">Data Roles & Permission</li>
</ol>
</nav>
@extends('layouts.base')
@section('content-header')
<div class="col-12">
<div class="container" style="display: contents">
<div class="row mb-2">
<div class="col-sm-6">
<h3 class="m-0"> Master Data</h3>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item"><a href="#">Admin</a></li>
<li class="breadcrumb-item active">Roles</li>
</ol>
</div>
</div>
</div>
</div>
<!-- End Breadcrumb -->
@endsection
<div class="row">
<div class="col-lg-12 d-flex align-items-stretch">
<div class="card w-100">
<div class="card-body p-4">
<div class="d-flex align-items-stretch">
<h5 class="card-title fw-semibold mb-4">Tabel Roles</h5>
<div class="d-inline ms-auto">
<a href="{{ route('roles.create') }}" class="btn btn-sm btn-success">
<i class="ti ti-user-plus"></i>&nbsp; Tambah
</a>
@section('content')
<div class="col-lg-12 col-md-12 col-sm-12 mt-2">
<div class="container" style="display: contents">
<div class="card">
<div class="card bg-warning" style="min-height:5px; border-radius:1px;"></div>
<div class="card-header mt-0 pt-0">
<div class="d-flex">
<h4>Daftar Role</h4>
<!-- Button trigger modal -->
<div class="ml-auto">
<a href="{{ route('roles.create') }}" class="btn btn-sm btn-primary"><i class="ti ti-edit"></i>
Tambah Role</a>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered text-nowrap mb-0 align-middle">
<thead class="text-dark fs-4">
</div>
<div class="card-body">
<div class="table-responsive mt-3">
<table id="tabelku" class="table table-hover display" style="width: 100%">
<thead>
<tr>
<th class="border-bottom-0" width="70px">
<h6 class="fw-semibold mb-0 text-center">No.</h6>
</th>
<th class="border-bottom-0">
<h6 class="fw-semibold mb-0">Name</h6>
</th>
<th class="border-bottom-0">
<h6 class="fw-semibold mb-0">Terakhir Diupdate</h6>
</th>
<th class="border-bottom-0" width="100px">
<h6 class="fw-semibold mb-0 text-center">Action</h6>
</th>
<th class="text-center">No</th>
<th>Nama Role</th>
<th>Terakhir Diupdate</th>
<th class="text-center"><i class="fas fa-cog"></i></th>
</tr>
</thead>
<tbody>
@ -66,16 +60,17 @@
<td class="border-bottom-0">
<h6 class="fw-normal mb-0 fs-4">{{ $role->updated_at }}</h6>
</td>
<td class="border-bottom-0">
<div class="d-flex align-items-center gap-2">
<td class="border-bottom-0 text-center">
<div class="d-flex align-items-center gap-2 text-center"
style="justify-content: center">
<a href="{{ route('roles.edit', $role->id) }}"
class="btn btn-sm btn-primary"><i class="ti ti-edit"></i> Ubah</a>
class="btn btn-sm btn-warning"><i class="ti ti-edit"></i> Ubah</a>
</div>
</td>
</tr>
@empty
<div class="alert alert-danger">
Data Post belum Tersedia.
Data Belum Tersedia.
</div>
@endforelse
</tbody>
@ -85,5 +80,19 @@
</div>
</div>
</div>
@endsection
@stop
@push('styles')
<!-- Toastr -->
<link rel="stylesheet" href="{{ asset('assets/plugins/toastr/toastr.min.css') }}">
@endpush
@push('scripts')
<!-- Toastr -->
<script src="{{ asset('assets/plugins/toastr/toastr.min.js') }}"></script>
<script>
// show toast
@if (Session::has('roles-message'))
toastr.{{ Session::get('roles-message.type') }}("{{ Session::get('roles-message.msg') }}")
@endif
</script>
@endpush

View File

@ -118,7 +118,7 @@
</button>
</div>
<div class="modal-body">
<form id="form-edit-user" method="post" enctype="multipart/form-data">
<form id="form-edit-user" method="put" enctype="multipart/form-data">
@csrf
<div class="form-group">
<label for="user-name-edit" class="col-form-label">Nama User:</label>
@ -131,14 +131,14 @@
<div class="form-group">
<label for="password-input_edit" class="col-form-label">Password User:</label>
<input type="text" class="form-control" id="password-input_edit" name="password_edit"
placeholder="Kosongkan jika tidak ingin mengubah password" required>
placeholder="Kosongkan jika tidak ingin mengubah password">
</div>
<div class="form-group" id="password_confirm_edit" style="display: none">
<label for="konfirmasi-password-input_edit" class="col-form-label">Konfirmasi Password
User:</label>
<input type="text" class="form-control" id="konfirmasi-password-input_edit"
placeholder="Kosongkan jika tidak ingin mengubah password"
name="password_confirmation_edit" required>
name="password_confirmation_edit">
</div>
<div class="form-group">
<label for="role-text" class="col-form-label">Role:</label>
@ -171,42 +171,11 @@
</button>
</div>
<div class="modal-body">
{{-- <form id="form-tambah-user" method="post" enctype="multipart/form-data">
@csrf
<div class="form-group">
<label for="user-name" class="col-form-label">Nama User:</label>
<input type="text" class="form-control" id="user-name" name="name" required>
</div>
<div class="form-group">
<label for="email-name" class="col-form-label">Email User:</label>
<input type="text" class="form-control" id="email-name" name="email" required>
</div>
<div class="form-group">
<label for="password-input" class="col-form-label">Password User:</label>
<input type="text" class="form-control" id="password-input" name="password" required>
</div>
<div class="form-group">
<label for="konfirmasi-password-input" class="col-form-label">Konfirmasi Password
User:</label>
<input type="text" class="form-control" id="konfirmasi-password-input"
name="password_confirmation" required>
</div>
<div class="form-group">
<label for="role-text" class="col-form-label">Role:</label>
<div class="form-group select2-primary">
<select class="select2" multiple="multiple" data-placeholder="Pilih role user" required
name="role_id[]" style="width: 100%;">
@foreach ($roles as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
</select>
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
<button type="submit" class="btn btn-primary" id="simpan-form-tambah">Simpan</button>
</div>
</form> --}}
<p id="title-terhapus">&hellip;</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Batal</button>
<button type="button" class="btn btn-danger button-hapus">Hapus</button>
</div>
</div>
</div>
@ -307,6 +276,16 @@
}
})
$('#konfirmasi-password-input_edit').on('keyup', function() {
if ($('#password-input_edit').val() == $('#konfirmasi-password-input_edit').val()) {
$('#konfirmasi-password-input_edit').removeClass('is-invalid')
$('#konfirmasi-password-input_edit').addClass('is-valid')
} else {
$('#konfirmasi-password-input_edit').removeClass('is-valid')
$('#konfirmasi-password-input_edit').addClass('is-invalid')
}
})
$(document).ready(function() {
// ajax tambah user
@ -335,89 +314,75 @@
// ajax edit user
$(document).on('click', '.btn-edit-user', function() {
var id = $(this).attr('data-id')
var data = JSON.parse($(this).attr('data-user'));
$('#user-name_edit').val(data.name)
$('#user-email_edit').val(data.email)
$('.edit_select2').val(data.role.map(x => x.id)).trigger('change')
$('#modal-default-edit').modal('show')
$('#form-edit-user').on('submit', function(e) {
// disable button submit
$('#simpan-form-tambah').attr('disabled', true)
e.preventDefault();
$.ajax({
url: "{{ url('users/update') }}" + '/' + data.id,
type: "PUT",
dataType: "json",
data: $(this).serialize(),
cache: false,
async: false,
success: function(response) {
// enable button submit on interval 1 detik
setTimeout(function() {
$('#simpan-form-tambah').attr('disabled', false)
}, 500);
toastr.success(response.meta.message)
$('#modal-default-edit').modal('hide')
$('#form-edit-user')[0].reset()
$('.edit_select2').val(null).trigger('change')
$('#konfirmasi-password-input_edit').removeClass('is-valid')
$('#tabelku').DataTable().ajax.reload()
},
error: function(response) {
// enable button submit on interval 1 detik
setTimeout(function() {
$('#simpan-form-tambah').attr('disabled', false)
}, 500);
toastr.error(response.responseJSON.meta.message)
}
})
})
})
// ajax hapus user
$(document).on('click', '.btn-hapus-user', function() {
var data = JSON.parse($(this).attr('data-user'));
var dataAppend = '<p>Apakah anda yakin ingin menghapus user <b>' + data.name +
'</b> email <b>' +
data.email + '</b> ?</p>';
$('#title-terhapus').html(dataAppend);
$('.button-hapus').attr('data-id', data.id);
$('#modal-default-hapus').modal('show');
})
$(document).on('click', '.button-hapus', function() {
var id = $(this).attr('data-id');
$.ajax({
url: "{{ url('users') }}" + '/' + id + '/edit',
type: "GET",
url: "{{ url('users/delete') }}" + '/' + id,
type: "DELETE",
dataType: "json",
cache: false,
async: false,
success: function(response) {
console.log(response);
var user = response.data.user;
$('#modal-default-edit').modal('show')
$('#user-name_edit').val(user.name)
$('#user-email_edit').val(user.email)
// set value select2
var roles = user.role;
var role_id = [];
$.each(roles, function(key, value) {
role_id.push(value.id)
})
$('.edit_select2').val(role_id).trigger('change')
$('#form-edit-user').on('submit', function(e) {
e.preventDefault();
$.ajax({
url: "{{ url('users') }}" + '/' + id,
type: "POST",
dataType: "json",
data: $(this).serialize(),
cache: false,
async: false,
success: function(response) {
toastr.success(response.meta.message)
$('#modal-default-edit').modal('hide')
$('#form-edit-user')[0].reset()
$('.edit_select2').val(null).trigger(
'change')
$('#konfirmasi-password-input_edit')
.removeClass('is-valid')
$('#tabelku').DataTable().ajax.reload()
},
error: function(response) {
toastr.error(response.responseJSON.meta
.message)
}
})
})
toastr.success(response.meta.message)
$('#modal-default-hapus').modal('hide')
$('#tabelku').DataTable().ajax.reload()
},
error: function(response) {
toastr.error(response.responseJSON.meta.message)
}
})
})
// ajax hapus user
$(document).on('click', '.btn-hapus-user', function() {
var id = $(this).attr('data-id')
Swal.fire({
title: 'Apakah anda yakin?',
text: "Data user akan dihapus secara permanen!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#007bff',
cancelButtonColor: '#dc3545',
confirmButtonText: 'Ya, hapus!',
cancelButtonText: 'Batal'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: "{{ url('admin/users') }}" + '/' + id,
type: "POST",
data: {
'_method': 'DELETE'
},
success: function(response) {
toastr.success(response.meta.message)
$('#tabelku').DataTable().ajax.reload()
},
error: function(response) {
toastr.error(response.responseJSON.meta.message)
}
})
}
})
})
})
</script>
@endpush