diff --git a/skolehjem/app/Http/Controllers/ContactController.php b/skolehjem/app/Http/Controllers/ContactController.php
index 3c2616b..e24b7c8 100644
--- a/skolehjem/app/Http/Controllers/ContactController.php
+++ b/skolehjem/app/Http/Controllers/ContactController.php
@@ -168,8 +168,6 @@ class ContactController extends Controller
''.
'';
}
- }else{
- $output.= "
Der er ingen resultater...
";
}
return Response($output);
}
diff --git a/skolehjem/app/Http/Controllers/EventController.php b/skolehjem/app/Http/Controllers/EventController.php
index 55866ba..3497ae3 100644
--- a/skolehjem/app/Http/Controllers/EventController.php
+++ b/skolehjem/app/Http/Controllers/EventController.php
@@ -6,6 +6,7 @@ use App\Event;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
+use Illuminate\Support\Facades\DB;
class EventController extends Controller
@@ -130,4 +131,44 @@ class EventController extends Controller
$event->delete();
return redirect()->route("events.index");
}
+
+
+ public function search(Request $request){
+ if($request->ajax()){
+ $output = "".
+ "Event Navn | ".
+ "Event Beskrivelse | ".
+ "Event Dato | ".
+ " | ".
+ " | ".
+ "
";
+ $events = DB::table('events')->where('name', 'LIKE',$request->search.'%')
+ ->orWhere('date','LIKE', $request->search.'%')
+ ->get();
+
+ if(count($events) !== 0){
+ foreach ($events as $key => $event){
+ $output.=''.
+ '' . $event->name . ' | '.
+ '' . $event->description .' | '.
+ '' . $event->date .' | '.
+ ' $event->id ]) . '"> | '.
+ ''.
+ ' | '.
+ '
';
+ }
+ }
+ return Response($output);
+ }
+ }
+
+
+
}
+
+
diff --git a/skolehjem/app/Http/Controllers/MenuPlanController.php b/skolehjem/app/Http/Controllers/MenuPlanController.php
index 7b33aaa..279bf1c 100644
--- a/skolehjem/app/Http/Controllers/MenuPlanController.php
+++ b/skolehjem/app/Http/Controllers/MenuPlanController.php
@@ -6,6 +6,7 @@ use App\ExternalLink;
use App\MenuPlan;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
+use Illuminate\Support\Facades\DB;
class MenuPlanController extends Controller
@@ -130,4 +131,43 @@ class MenuPlanController extends Controller
$menuplan->delete();
return redirect()->route("menu-plans.index");
}
+
+
+ public function search(Request $request){
+ if($request->ajax()){
+ $output = "".
+ "Uge | ".
+ "Mandag | ".
+ "Tirsdag | ".
+ "Onsdag | ".
+ "Torsdag | ".
+ " | ".
+ " | ".
+ "
";
+ $menuplans = DB::table('menu_plans')->where('week', 'LIKE',$request->search.'%')->get();
+
+ if(count($menuplans) !== 0){
+ foreach ($menuplans as $key => $menuplan){
+ $output.=''.
+ '' . $menuplan->week . ' | '.
+ '' . $menuplan->monday . ' | '.
+ '' . $menuplan->tuesday . ' | '.
+ '' . $menuplan->wednesday .' | '.
+ '' . $menuplan->thursday .' | '.
+ ' $menuplan->id ]) . '"> | '.
+ ''.
+ ' | '.
+ '
';
+ }
+ }
+ return Response($output);
+ }
+ }
+
+
}
diff --git a/skolehjem/app/Http/Controllers/RolesController.php b/skolehjem/app/Http/Controllers/RolesController.php
index 093cbe8..801a275 100644
--- a/skolehjem/app/Http/Controllers/RolesController.php
+++ b/skolehjem/app/Http/Controllers/RolesController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
+use Illuminate\Support\Facades\DB;
use Spatie\Permission\Models\Role;
class rolesController extends Controller
@@ -115,4 +116,38 @@ class rolesController extends Controller
$role->delete();
return redirect()->route("roles.index");
}
+
+
+ public function search(Request $request){
+ if($request->ajax()){
+ $output = "".
+ "Navn | ".
+ "Beskrivelse | ".
+ " | ".
+ " | ".
+ "
";
+ $roles = DB::table('roles')->where('name', 'LIKE',$request->search.'%')->get();
+
+ if(count($roles) !== 0){
+ foreach ($roles as $key => $role){
+ $output.=''.
+ '' . $role->name . ' | '.
+ '' . $role->description . ' | '.
+ ' $role->id ]) . '"> | '.
+ ''.
+ ' | '.
+ '
';
+ }
+ }
+ return Response($output);
+ }
+ }
+
+
+
}
diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php
index 535b54b..afb8e6f 100644
--- a/skolehjem/app/Http/Controllers/UserController.php
+++ b/skolehjem/app/Http/Controllers/UserController.php
@@ -256,4 +256,58 @@ class UserController extends Controller
}
+ public function search(Request $request){
+ if($request->ajax()){
+ $output = "".
+ "Fornavn | ".
+ "Efternavn | ".
+ "Email | ".
+ "Tlf nr | ".
+ "Rolle(r) | ".
+ " | ".
+ " | ".
+ "
";
+ $users = DB::table('users')->where('name_first', 'LIKE',$request->search.'%')
+ ->orWhere('name_last','LIKE', $request->search.'%')
+ ->orWhere('phone','LIKE', $request->search.'%')
+ ->orWhere('email','LIKE',$request->search. '%')->get();
+
+ if(count($users) !== 0){
+ foreach ($users as $key => $user){
+ $roles = null;
+ $rolesString = null;
+
+ foreach (User::all() as $usr) {
+ if($usr->id == $user->id)
+ $roles = $usr->roles;
+ }
+
+ for($i = 0; $i < count($roles); $i++) {
+ if(count($roles)-1 != $i) {
+ $rolesString .= $roles[$i]->name.",";
+ }else {
+ $rolesString = $roles[$i]->name;
+ }
+ }
+
+ $output.=''.
+ '' . $user->name_first . ' | '.
+ '' . $user->name_last . ' | '.
+ '' . $user->email . ' | '.
+ '' . $user->phone .' | '.
+ '' . $rolesString .' | '.
+ ' $user->id ]) . '"> | '.
+ ''.
+ ' | '.
+ '
';
+ }
+ }
+ return Response($output);
+ }
+ }
}
diff --git a/skolehjem/resources/views/admin/contacts/index.blade.php b/skolehjem/resources/views/admin/contacts/index.blade.php
index 1321fcf..da10d16 100644
--- a/skolehjem/resources/views/admin/contacts/index.blade.php
+++ b/skolehjem/resources/views/admin/contacts/index.blade.php
@@ -16,7 +16,7 @@
@@ -50,7 +50,6 @@
@@ -40,4 +47,24 @@
{{ $events->links() }}
+
+
+
+
@endsection
diff --git a/skolehjem/resources/views/admin/menuplans/index.blade.php b/skolehjem/resources/views/admin/menuplans/index.blade.php
index d63d272..83e091a 100644
--- a/skolehjem/resources/views/admin/menuplans/index.blade.php
+++ b/skolehjem/resources/views/admin/menuplans/index.blade.php
@@ -10,8 +10,15 @@
@endsection
@section("content")
+
{{ $menuPlans->links() }}
+
+
+
+
+
@endsection
diff --git a/skolehjem/resources/views/admin/roles/index.blade.php b/skolehjem/resources/views/admin/roles/index.blade.php
index fe3e3e7..554eb3b 100644
--- a/skolehjem/resources/views/admin/roles/index.blade.php
+++ b/skolehjem/resources/views/admin/roles/index.blade.php
@@ -10,8 +10,16 @@
@endsection
@section("content")
+
@@ -35,4 +43,26 @@
@endforeach
+
+
+
+
+
+
@endsection
diff --git a/skolehjem/resources/views/admin/users/index.blade.php b/skolehjem/resources/views/admin/users/index.blade.php
index 6f9aa3a..42045a6 100644
--- a/skolehjem/resources/views/admin/users/index.blade.php
+++ b/skolehjem/resources/views/admin/users/index.blade.php
@@ -10,11 +10,17 @@
@endsection
@section("content")
+
@@ -54,4 +60,26 @@
@endforeach
{{ $users->links() }}
+
+
+
+
+
+
@endsection
diff --git a/skolehjem/resources/views/admin/washing-reservations/index.blade.php b/skolehjem/resources/views/admin/washing-reservations/index.blade.php
index 46939c3..3fbdf89 100644
--- a/skolehjem/resources/views/admin/washing-reservations/index.blade.php
+++ b/skolehjem/resources/views/admin/washing-reservations/index.blade.php
@@ -12,6 +12,12 @@
@section("content")
diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php
index da4b509..00e6079 100644
--- a/skolehjem/routes/web.php
+++ b/skolehjem/routes/web.php
@@ -31,6 +31,13 @@ Route::get("/account/editpass", "UserController@accounteditpass")->name("users.a
Route::post("/account/update", "UserController@update")->name("users.accountupdate");
Route::get("phones", "PhoneController@index")->name("phones.index");
Route::get("/contactsapi", "ContactController@search")->name("contacts.search");
+Route::get("/eventsapi", "EventController@search")->name("events.search");
+Route::get("/menuplansapi", "MenuPlanController@search")->name("menu-plans.search");
+Route::get("/rolesapi", "RolesController@search")->name("roles.search");
+Route::get("/userapi", "UserController@search")->name("users.search");
+
+
+
Route::resource("contacts", "ContactController");
Route::resource("menu-plans", "MenuPlanController");