diff --git a/skolehjem/app/Http/Controllers/LocationController.php b/skolehjem/app/Http/Controllers/LocationController.php
index 5a6f9a4..12152b3 100644
--- a/skolehjem/app/Http/Controllers/LocationController.php
+++ b/skolehjem/app/Http/Controllers/LocationController.php
@@ -131,4 +131,12 @@ class LocationController extends Controller
{
}
+
+ public function nameCheck(Request $request){
+ $locations = Location::query()->where('name', 'LIKE',$request->nameCheck)->get();
+ if(count($locations) > 0 && $request->nameCheck !== NULL){
+ return 1;
+ }
+ }
+
}
diff --git a/skolehjem/app/Http/Controllers/WashingMachineController.php b/skolehjem/app/Http/Controllers/WashingMachineController.php
index d4e30f3..bb9965a 100644
--- a/skolehjem/app/Http/Controllers/WashingMachineController.php
+++ b/skolehjem/app/Http/Controllers/WashingMachineController.php
@@ -153,4 +153,15 @@ class WashingMachineController extends Controller
return redirect()->route("washing-machines.index");
}
+
+
+
+
+ public function nameCheck(Request $request){
+ $washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->get();
+ if(count($washing) > 0 && $request->nameCheck !== NULL){
+ return 1;
+ }
+ }
+
}
diff --git a/skolehjem/resources/views/admin/locations/create.blade.php b/skolehjem/resources/views/admin/locations/create.blade.php
index bf85ec5..e6d2361 100644
--- a/skolehjem/resources/views/admin/locations/create.blade.php
+++ b/skolehjem/resources/views/admin/locations/create.blade.php
@@ -10,12 +10,13 @@
@endsection
@section("content")
-
Opret Lokation
+ Opret Lokation
@endsection
@section("scripts")
@@ -28,5 +29,61 @@
}
);
});
+
+
+
+ //Dont delete me, if the user reloads the pages with text in the text-box this code runs.
+ $(document).ready(function () {
+ $value = $('#name').val();
+ $.ajax({
+ type: 'get',
+ url: '{{route('locations.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);
+ }
+ });
+ });
+
+ $('#name').on('keyup', function () {
+ $value = $(this).val();
+ $.ajax({
+ type: 'get',
+ url: '{{route('locations.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);
+ }
+ });
+ })
+
+
@endsection
diff --git a/skolehjem/resources/views/admin/washing-machines/create.blade.php b/skolehjem/resources/views/admin/washing-machines/create.blade.php
index 942c6e8..a8a803b 100644
--- a/skolehjem/resources/views/admin/washing-machines/create.blade.php
+++ b/skolehjem/resources/views/admin/washing-machines/create.blade.php
@@ -10,10 +10,11 @@
@endsection
@section("content")
- Opret Vaskemaskine:
+ Opret Vaskemaskine:
@endsection
@section("scripts")
@@ -39,5 +40,60 @@
}
);
});
+
+
+
+ //Dont delete me, if the user reloads the pages with text in the text-box this code runs.
+ $(document).ready(function () {
+ $value = $('#name').val();
+ $.ajax({
+ type: 'get',
+ url: '{{route('washing-machines.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);
+ }
+ });
+ });
+
+ $('#name').on('keyup', function () {
+ $value = $(this).val();
+ $.ajax({
+ type: 'get',
+ url: '{{route('washing-machines.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);
+ }
+ });
+ })
+
@endsection
diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php
index ce7055d..c76fc21 100644
--- a/skolehjem/routes/web.php
+++ b/skolehjem/routes/web.php
@@ -62,6 +62,9 @@ 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");
+Route::get("/locationsCheck", "LocationController@nameCheck")->name("locations.nameCheck");
+Route::get("/washingCheck", "WashingMachineController@nameCheck")->name("washing-machines.nameCheck");
+