Ekapp/skolehjem/resources/views/admin/roles/create.blade.php

86 lines
2.9 KiB
PHP
Raw Normal View History

2020-06-30 09:31:12 +00:00
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Rolle - Opret
@endsection
@section("path")
<a href="{{ route('roles.create') }}" class="text-white">Opret Rolle</a> /
@endsection
@section("content")
2020-08-14 09:22:51 +00:00
<h1 id="errormesseages" >Opret Rolle:</h1>
2020-06-30 09:31:12 +00:00
<form method="post" action="{{ route("roles.store") }}">
@csrf
<label for="name">Navn:</label>
2020-08-17 08:21:02 +00:00
<label hidden id="error" for="errormesseages">Rolle navnet findes allerede</label>
2020-06-30 09:31:12 +00:00
<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>
2020-08-14 09:22:51 +00:00
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
2020-06-30 09:31:12 +00:00
</form>
@endsection
@section("scripts")
<script>
$(function() {
$('form').areYouSure(
{
message: 'It looks like you have been editing something. '
+ 'If you leave before saving, your changes will be lost.'
}
);
});
2020-08-14 09:22:51 +00:00
$(document).ready(function () {
$value = $('#name').val();
$.ajax({
type: 'get',
url: '{{route('roles.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#name').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('roles.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
</script>
@endsection