v0.9.15g - NameCheck

This commit is contained in:
Neerholt 2020-08-17 09:21:47 +02:00
parent fce970de65
commit ea623a72ca
7 changed files with 140 additions and 6 deletions

View File

@ -206,4 +206,14 @@ class MenuPlanController extends Controller
return $pdf->stream("menuplan_uge_".$menuPlan->week.".pdf"); return $pdf->stream("menuplan_uge_".$menuPlan->week.".pdf");
} }
public function nameCheck(Request $request){
$menuplan = MenuPlan::query()->where('week', 'LIKE',$request->nameCheck)->get();
if(count($menuplan) > 0 && $request->nameCheck !== NULL){
return 1;
}
}
} }

View File

@ -153,4 +153,13 @@ class NewsController extends Controller
$news->delete(); $news->delete();
return redirect()->route("news.index"); return redirect()->route("news.index");
} }
public function nameCheck(Request $request){
$news = News::query()->where('subname', 'LIKE',$request->nameCheck)->get();
if(count($news) > 0 && $request->nameCheck !== NULL){
return 1;
}
}
} }

View File

@ -94,7 +94,6 @@
url: '{{route('events.nameCheck')}}', url: '{{route('events.nameCheck')}}',
data: {'nameCheck':$value}, data: {'nameCheck':$value},
success:function (data) { success:function (data) {
console.log(data);
if(data){ if(data){
$("#error").show(100); $("#error").show(100);
$("#error").css('color', 'red'); $("#error").css('color', 'red');

View File

@ -81,6 +81,8 @@
); );
}); });
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () { $(document).ready(function () {
$value = $('#title').val(); $value = $('#title').val();
$.ajax({ $.ajax({
@ -88,7 +90,6 @@
url: '{{route('guides.nameCheck')}}', url: '{{route('guides.nameCheck')}}',
data: {'nameCheck':$value}, data: {'nameCheck':$value},
success:function (data) { success:function (data) {
console.log(data);
if(data){ if(data){
$("#error").show(100); $("#error").show(100);
$("#error").css('color', 'red'); $("#error").css('color', 'red');

View File

@ -23,10 +23,11 @@
} }
</style> </style>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"> <link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<h1>Opret Menuplan:</h1> <h1 id="errormesseages" >Opret Menuplan:</h1>
<form action="{{ action('MenuPlanController@store') }}" method="post" enctype="multipart/form-data"> <form action="{{ action('MenuPlanController@store') }}" method="post" enctype="multipart/form-data">
@csrf @csrf
<label for="week">Uge nr.</label> <label for="week">Uge nr.</label>
<label hidden id="error" for="errormesseages">Menuplan findes allerede</label>
<input type="number" name="week" id="week" min="1" max="53" placeholder="1" required> <input type="number" name="week" id="week" min="1" max="53" placeholder="1" required>
<div id="editor"> <div id="editor">
<h2 class="ql-align-center"><strong>Mandag:</strong></h2> <h2 class="ql-align-center"><strong>Mandag:</strong></h2>
@ -53,7 +54,7 @@
<input id="fileuploade" type="file" name="resource"> <input id="fileuploade" type="file" name="resource">
<input type="submit" class="btn btn-dark text-white" value="Opret Menuplan"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Opret Menuplan">
</form> </form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script> <script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
@ -107,6 +108,62 @@
} }
change(); change();
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#week').val();
$.ajax({
type: 'get',
url: '{{route('menuplans.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
console.log(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);
}
});
});
$('#week').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('menuplans.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> </script>
@endsection @endsection

View File

@ -16,14 +16,15 @@
} }
</style> </style>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"> <link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<h1>Opret Nyhed</h1> <h1 id="errormesseages" >Opret Nyhed</h1>
<form method="post" action="{{ route("news.store") }}"> <form method="post" action="{{ route("news.store") }}">
@csrf @csrf
<label for="title">Titel nyheden:</label> <label for="title">Titel nyheden:</label>
<label hidden id="error" for="errormesseages">Dette navn findes allerede</label>
<input type="text" name="subname" id="title" placeholder="OBS: Menuplanen er ændret" required> <input type="text" name="subname" id="title" placeholder="OBS: Menuplanen er ændret" required>
<div id="editor"></div> <div id="editor"></div>
<textarea name="content" class="d-none" id="hiddenArea"></textarea> <textarea name="content" class="d-none" id="hiddenArea"></textarea>
<input type="submit" class="btn btn-dark text-white" value="Opret"> <input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
</form> </form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script> <script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
@ -65,5 +66,60 @@
} }
); );
}); });
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#title').val();
$.ajax({
type: 'get',
url: '{{route('news.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
console.log(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);
}
});
});
$('#title').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('news.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> </script>
@endsection @endsection

View File

@ -60,6 +60,8 @@ Route::get("/eventCheck", "EventController@nameCheck")->name("events.nameCheck")
Route::get("/roleCheck", "RolesController@nameCheck")->name("roles.nameCheck"); Route::get("/roleCheck", "RolesController@nameCheck")->name("roles.nameCheck");
Route::get("/usersCheck", "UserController@nameCheck")->name("users.nameCheck"); Route::get("/usersCheck", "UserController@nameCheck")->name("users.nameCheck");
Route::get("/guidesCheck", "GuideController@nameCheck")->name("guides.nameCheck"); Route::get("/guidesCheck", "GuideController@nameCheck")->name("guides.nameCheck");
Route::get("/newsCheck", "NewsController@nameCheck")->name("news.nameCheck");
Route::get("/menuplanCheck", "MenuPlanController@nameCheck")->name("menuplans.nameCheck");