v0.10.15l - Made role permissions semi done, sometimes it works sometimes it doesn't, it needs some touch up
This commit is contained in:
parent
5766770a4b
commit
a766bfea95
skolehjem
|
@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class rolesController extends Controller
|
||||
{
|
||||
|
@ -57,6 +58,13 @@ class rolesController extends Controller
|
|||
"description" => "required|max:255"
|
||||
]);
|
||||
|
||||
$brugerPermissions = new Collection();
|
||||
if (!$request->value === null) {
|
||||
foreach ($request->value as $valuee) {
|
||||
$brugerPermissions->add(\Spatie\Permission\Models\Permission::query()->where("name", "=", $valuee)->first());
|
||||
}
|
||||
}
|
||||
|
||||
$role = new Role($requestRole);
|
||||
|
||||
$allRoles = Role::query()->where('name', '=', $request->name)->get();
|
||||
|
@ -66,11 +74,16 @@ class rolesController extends Controller
|
|||
return redirect()->route("roles.store");
|
||||
else { // Else - Create it
|
||||
$role->save();
|
||||
|
||||
if (!$brugerPermissions->isEmpty()) {
|
||||
foreach ($brugerPermissions as $permission) {
|
||||
\Spatie\Permission\Models\Role::query()->find($role->id)->givePermissionTo($permission);
|
||||
}
|
||||
}
|
||||
|
||||
$roles = Role::query()->paginate($request->input("limit", 20));
|
||||
return redirect()->route("roles.index", ['roles' => $roles]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,18 @@
|
|||
td > p, td > input {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.form-text {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: #6c757d !important;
|
||||
}
|
||||
</style>
|
||||
<h1 id="errormesseages" >Opret Rolle:</h1>
|
||||
<form method="post" action="{{ route("roles.store") }}">
|
||||
|
@ -23,136 +35,208 @@
|
|||
<input type="text" name="name" id="name" placeholder="Admin" required>
|
||||
<label for="name">Beskrivelse:</label>
|
||||
<input type="text" name="description" id="description" placeholder="Admin rollen bruges til administratorene" required>
|
||||
<table class="tbl mt-2 mb-2">
|
||||
<tr>
|
||||
<td>Konto</td>
|
||||
<td>Beskrivelse</td>
|
||||
<td>Se Account</td>
|
||||
<td>Ændre Billede</td>
|
||||
<td>Ændre Oplysninger</td>
|
||||
<td>Ændre Password</td>
|
||||
<td>Forgot Password</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Konto</td>
|
||||
<td>Empty</td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="tbl mt-2 mb-2" >
|
||||
<tr><!--Header Start-->
|
||||
<td>Side</td>
|
||||
<td>Beskrivelse</td>
|
||||
<td>Create</td>
|
||||
<td>Read</td>
|
||||
<td>Update</td>
|
||||
<td>Delete</td>
|
||||
<td>Fuld Kontrol</td>
|
||||
</tr><!--Header Slut-->
|
||||
<tr><!--Bruger Start-->
|
||||
<td>Brugere</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr><!--Bruger Start-->
|
||||
<tr>
|
||||
<td>Roller</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nyheder</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Menuplan</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Aktiviteter</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lokation</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Vaskemaskiner</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Resevationer</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Kontakter</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Vejledning</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Feedback</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
<td><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="mb-2" style="width: 100%;">
|
||||
<button id="kontoButton" type="button" class="btn btn-sde-blue mb-1 mr-1" value="konto">Konto rettigheder</button>
|
||||
<button id="adminButton" type="button" class="btn btn-sde-blue mb-1">Admin rettigheder</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="konto">
|
||||
<small class="form-text text-muted">Her kan alle basale rettigheder for appens forbrugere slås til eller fra.</small>
|
||||
<table class="tbl mb-2">
|
||||
<tr>
|
||||
<th>Konto</th>
|
||||
<th>Beskrivelse</th>
|
||||
<th>Create</th>
|
||||
<th>Read</th>
|
||||
<th>Delete</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Konto</td>
|
||||
<td><p>Egen bruger</p></td>
|
||||
<td></td>
|
||||
<td><input type="checkbox" name="value[]" value="ownuser.edit"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nyheder</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td></td>
|
||||
<td><input type="checkbox" name="value[]" value="news.show"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Menuplan</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Aktiviteter</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Reservationer</td>
|
||||
<td>Empty</td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Kontakter</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Vejledning</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Feedback</td>
|
||||
<td>Empty</td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="admin">
|
||||
<small class="form-text text-muted">Her kan alle rettigheder for administrationssiden slås til eller fra.</small>
|
||||
<table class="tbl mb-2" >
|
||||
<tr><!--Header Start-->
|
||||
<th>Side</th>
|
||||
<th>Beskrivelse</th>
|
||||
<th>Create</th>
|
||||
<th>Read</th>
|
||||
<th>Update</th>
|
||||
<th>Delete</th>
|
||||
<th>Fuld Kontrol</th>
|
||||
</tr><!--Header Slut-->
|
||||
<tr>
|
||||
<td>Admin Panel</td>
|
||||
<td><p>Adgang til admin panelet</p></td>
|
||||
<td></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr><!--Bruger Start-->
|
||||
<td>Brugere</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr><!--Bruger Start-->
|
||||
<tr>
|
||||
<td>Roller</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nyheder</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Menuplan</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Aktiviteter</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Lokation</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Vaskemaskiner</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Reservationer</td>
|
||||
<td>Empty</td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Kontakter</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Vejledning</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Feedback</td>
|
||||
<td><p>Empty</p></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
<td><input type="checkbox" name="value[]" value="Bike"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
|
||||
</form>
|
||||
@endsection
|
||||
|
@ -216,5 +300,36 @@
|
|||
}
|
||||
});
|
||||
})
|
||||
|
||||
//User hide permissions
|
||||
|
||||
$('#konto').hide();
|
||||
$('#admin').hide();
|
||||
|
||||
|
||||
//Show konto settings
|
||||
$("#kontoButton").click(function(){
|
||||
var value = $('#kontoButton').text();
|
||||
if(value === 'Konto rettigheder'){
|
||||
$('#konto').slideDown('slow');
|
||||
$('#kontoButton').html('Luk konto rettigheder')
|
||||
}else{
|
||||
$('#konto').slideUp('slow');
|
||||
$('#kontoButton').html('Konto rettigheder')
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Show admin permissions
|
||||
$("#adminButton").click(function(){
|
||||
var value = $('#adminButton').text();
|
||||
if(value === 'Admin rettigheder'){
|
||||
$('#admin').slideDown('slow');
|
||||
$('#adminButton').html('Luk admin rettigheder')
|
||||
}else{
|
||||
$('#admin').slideUp('slow');
|
||||
$('#adminButton').html('Admin rettigheder')
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
|
Loading…
Reference in New Issue