137 lines
6.8 KiB
PHP
137 lines
6.8 KiB
PHP
@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>
|
|
@endsection
|
|
|
|
@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>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">
|
|
@if (count($errors) > 0)
|
|
<div class="alert alert-danger">
|
|
<strong>Whoops!</strong> There were some problems with your input.<br><br>
|
|
<ul>
|
|
@foreach ($errors->all() as $error)
|
|
<li>{{ $error }}</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
@endif
|
|
|
|
<form method="POST" action="{{ route('roles.update', $role->id) }}" id="formCreate">
|
|
@method('PUT')
|
|
@csrf
|
|
<div class="row">
|
|
<div class="col-xs-12 col-sm-12 col-md-12 mt-2">
|
|
<div class="form-group">
|
|
<strong>Name:</strong>
|
|
<input type="text" class="form-control" placeholder="Role Name" name="name"
|
|
value="{{ $role->name }}">
|
|
</div>
|
|
</div>
|
|
<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">
|
|
<h5>{{ $key }}</h5>
|
|
<table class="table table-hover table-bordered">
|
|
<tr id="checkboxnya" style="background: grey !important">
|
|
<td scope="col" width="1%" style="background: grey !important">
|
|
<input type="checkbox" name="all_permission" class="check"
|
|
id="allpermission">
|
|
</td>
|
|
<td scope="col" width="20%" style="background: grey !important">
|
|
Name</td>
|
|
<td scope="col" width="1%" style="background: grey !important">
|
|
Route</td>
|
|
<td scope="col" width="1%" style="background: grey !important">
|
|
Guard</td>
|
|
</tr>
|
|
@foreach ($permission as $item)
|
|
<tr>
|
|
<td>
|
|
<input type="checkbox" name="permission[{{ $item->name }}]"
|
|
value="{{ $item->name }}" value="{{ $item->name }}"
|
|
class='permission'
|
|
{{ in_array($item->name, $rolePermissions) ? 'checked' : '' }}>
|
|
</td>
|
|
<td>{{ $item->desc }}</td>
|
|
<td>{{ $item->name }}</td>
|
|
<td>{{ $item->guard_name }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</table>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
|
|
<div class="col-xs-12 col-sm-12 col-md-12 text-end mt-3">
|
|
<a href="{{ route('roles.index') }}" class="btn btn-info">Batalkan</a>
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
$('input[type="checkbox"].check').on('change', function() {
|
|
var check = this;
|
|
$(check).closest('tr').nextUntil('tr[id]').find('input[type="checkbox"]').prop(
|
|
'checked',
|
|
check
|
|
.checked);
|
|
});
|
|
$(document).ready(function() {
|
|
$('#allpermission').click(function() {
|
|
if ($(this).is(':checked')) {
|
|
$('.check').prop('checked', true);
|
|
$('.permission').prop('checked', true);
|
|
} else {
|
|
$('.check').prop('checked', false);
|
|
$('.permission').prop('checked', false);
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
@endpush
|