From 505ed3710bdb233bc6561b976dac123c76fb66a3 Mon Sep 17 00:00:00 2001 From: frederikpyt Date: Tue, 22 Sep 2020 09:07:36 +0200 Subject: [PATCH] v1.3.4 - Small fixes --- .../Controllers/WashingMachineController.php | 70 +++++++++++++++++++ .../views/admin/guides/index.blade.php | 2 - .../views/admin/locations/index.blade.php | 2 - .../views/app/contacts/index.blade.php | 1 - .../views/app/events/index.blade.php | 1 - .../views/app/guides/index.blade.php | 1 - .../views/app/menuplans/index.blade.php | 1 - .../app/washing-reservations/index.blade.php | 1 - skolehjem/routes/web.php | 3 + 9 files changed, 73 insertions(+), 9 deletions(-) diff --git a/skolehjem/app/Http/Controllers/WashingMachineController.php b/skolehjem/app/Http/Controllers/WashingMachineController.php index 8e4b2b1..f476d38 100644 --- a/skolehjem/app/Http/Controllers/WashingMachineController.php +++ b/skolehjem/app/Http/Controllers/WashingMachineController.php @@ -154,6 +154,76 @@ class WashingMachineController extends Controller return redirect()->route("washing-machines.index"); } + public function search(Request $request) + { + if ($request->ajax()) { + $output = "" . + "Navn" . + "Lokation" . + "\"Update\"" . + "\"Delete\"" . + ""; + + if ($request->option !== 'all') { + $machines = DB::table('washing_machines') + ->join('locations', 'washing_machines.location_id', '=', 'locations.id') + ->select(DB::raw('washing_machines.name as washing_name, locations.name as location_name, washing_machines.id as id')) + ->where('locations.id', '=', $request->option) + ->get(); + + if (count($machines) !== 0) { + foreach ($machines as $machine) { + $output .= '' . + '' . $machine->washing_name . '' . + '' . $machine->location_name . '' . + ' $machine->id]) . '">Update' . + '
$machine->id]) . '" class="w-100 nostyle">' . + csrf_field() . + method_field("delete") . + + '' . + '
' . + '' . + ''; + } + } else { + $output .= '' . + 'Det er ikke blivet oprettet nogen vaskmaskine på denne lokation endnu' . + '' . + '' . + '' . + ''; + } + } elseif ($request->option === "all") { + $machines = WashingMachine::all(); + + if (count($machines) !== 0) { + foreach ($machines as $machine) { + $output .= '' . + '' . $machine->name . '' . + '' . Location::query()->where("id", "=", $machine->location_id)->first()->name . '' . + ' $machine->id]) . '">Update' . + '
' . + csrf_field() . + method_field("delete") . + '' . + '
' . + '' . + ''; + } + } else { + $output .= '' . + 'Det er ikke blivet oprettet nogen vaskmaskine på denne lokation endnu' . + '' . + '' . + '' . + ''; + } + } + return Response($output); + } + } + //Used for checking if the currently typed washingmachine name is unique. Create version public function nameCheck(Request $request){ $washing = WashingMachine::query()->where('name', 'LIKE',$request->nameCheck)->where('location_id', '=', $request->location)->get(); diff --git a/skolehjem/resources/views/admin/guides/index.blade.php b/skolehjem/resources/views/admin/guides/index.blade.php index 95bed94..186b062 100644 --- a/skolehjem/resources/views/admin/guides/index.blade.php +++ b/skolehjem/resources/views/admin/guides/index.blade.php @@ -81,6 +81,4 @@ @endforeach - - {{ $guides->links() }} @endsection diff --git a/skolehjem/resources/views/admin/locations/index.blade.php b/skolehjem/resources/views/admin/locations/index.blade.php index 9e15551..48d682b 100644 --- a/skolehjem/resources/views/admin/locations/index.blade.php +++ b/skolehjem/resources/views/admin/locations/index.blade.php @@ -45,6 +45,4 @@ @endforeach - - {{ $locations->links() }} @endsection diff --git a/skolehjem/resources/views/app/contacts/index.blade.php b/skolehjem/resources/views/app/contacts/index.blade.php index 25ee70a..966ed1f 100644 --- a/skolehjem/resources/views/app/contacts/index.blade.php +++ b/skolehjem/resources/views/app/contacts/index.blade.php @@ -20,7 +20,6 @@ {{__('msg.ring')}} @endif @endforeach - {{ $contacts->links() }} @else

{{__('msg.dereringenkontakter')}}!

@endif diff --git a/skolehjem/resources/views/app/events/index.blade.php b/skolehjem/resources/views/app/events/index.blade.php index 8bf8653..656405b 100644 --- a/skolehjem/resources/views/app/events/index.blade.php +++ b/skolehjem/resources/views/app/events/index.blade.php @@ -117,7 +117,6 @@ @endforeach - {{ $events->links() }} @else

{{__('msg.dereringenaktiviteter')}}!

@endif diff --git a/skolehjem/resources/views/app/guides/index.blade.php b/skolehjem/resources/views/app/guides/index.blade.php index 09cac02..6d661b3 100644 --- a/skolehjem/resources/views/app/guides/index.blade.php +++ b/skolehjem/resources/views/app/guides/index.blade.php @@ -55,7 +55,6 @@ @endforeach - {{ $guides->links() }} @else

{{__('msg.dereringenvejledninger')}}.

@endif diff --git a/skolehjem/resources/views/app/menuplans/index.blade.php b/skolehjem/resources/views/app/menuplans/index.blade.php index bd7e4f3..1006446 100644 --- a/skolehjem/resources/views/app/menuplans/index.blade.php +++ b/skolehjem/resources/views/app/menuplans/index.blade.php @@ -37,5 +37,4 @@

{{__('msg.dereringenmenuplanerdenneuge')}}!

@endif - {{ $menuPlans->links() }} @endsection diff --git a/skolehjem/resources/views/app/washing-reservations/index.blade.php b/skolehjem/resources/views/app/washing-reservations/index.blade.php index 95e91ab..3c6666b 100644 --- a/skolehjem/resources/views/app/washing-reservations/index.blade.php +++ b/skolehjem/resources/views/app/washing-reservations/index.blade.php @@ -33,7 +33,6 @@ @if(count($reservations) < 1 || $washingreservations == 0)

{{__('msg.duharingenreservationer')}}.

@else - {{ $reservations->links() }} @endif {{__('msg.reservervaskemaskine')}} diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php index 656c571..162c366 100644 --- a/skolehjem/routes/web.php +++ b/skolehjem/routes/web.php @@ -44,6 +44,9 @@ Route::post("/feedbacks/store", "FeedbackController@storeajax")->name("feedbacks Route::get("/signup", "UserController@signup")->name("users.signup"); Route::post("/signupStore", "UserController@signupStore")->name("users.signupStore"); +//Search +Route::get("/machineapi", "WashingMachineController@search")->name("washing-machines.search"); + //Cookies Route::get("/languages", "UserController@setLanguages")->name("users.setLanguages"); Route::get("/darkmode", "UserController@setDarkMode")->name("users.setDarkMode");