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");
}
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();
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')}}',
data: {'nameCheck':$value},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#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 () {
$value = $('#title').val();
$.ajax({
@ -88,7 +90,6 @@
url: '{{route('guides.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#error").css('color', 'red');

View File

@ -23,10 +23,11 @@
}
</style>
<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">
@csrf
<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>
<div id="editor">
<h2 class="ql-align-center"><strong>Mandag:</strong></h2>
@ -53,7 +54,7 @@
<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>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
@ -107,6 +108,62 @@
}
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>
@endsection

View File

@ -16,14 +16,15 @@
}
</style>
<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") }}">
@csrf
<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>
<div id="editor"></div>
<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>
<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>
@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("/usersCheck", "UserController@nameCheck")->name("users.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");