diff --git a/skolehjem/app/Http/Controllers/ContactController.php b/skolehjem/app/Http/Controllers/ContactController.php index 7251f4b..e3e706c 100644 --- a/skolehjem/app/Http/Controllers/ContactController.php +++ b/skolehjem/app/Http/Controllers/ContactController.php @@ -57,7 +57,7 @@ class ContactController extends Controller "contactname" => "required|max:255", "title" => "required|max:255", "email" => "required|max:255", - "phone" => "required|max:255", + "phone" => "max:255", ]); $contact = new Contact($requestContact); diff --git a/skolehjem/app/Http/Controllers/GuideController.php b/skolehjem/app/Http/Controllers/GuideController.php index 0a85ad7..7c73f01 100644 --- a/skolehjem/app/Http/Controllers/GuideController.php +++ b/skolehjem/app/Http/Controllers/GuideController.php @@ -9,18 +9,18 @@ use Illuminate\Http\Request; class GuideController extends Controller { - /* + public function __construct() { $this->middleware([ "auth" ]); - $this->middleware([ "check.auth:contact.list" ])->only("index"); - $this->middleware([ "check.auth:contact.show" ])->only("show"); - $this->middleware([ "check.auth:contact.create" ])->only("create", "store"); - $this->middleware([ "check.auth:contact.edit" ])->only("edit", "update"); - $this->middleware([ "check.auth:contact.delete" ])->only("delete"); + $this->middleware([ "check.auth:guides.list" ])->only("index"); + $this->middleware([ "check.auth:guides.show" ])->only("show"); + $this->middleware([ "check.auth:guides.create" ])->only("create", "store"); + $this->middleware([ "check.auth:guides.edit" ])->only("edit", "update"); + $this->middleware([ "check.auth:guides.delete" ])->only("delete"); } - */ + /** diff --git a/skolehjem/app/Http/Controllers/LocationController.php b/skolehjem/app/Http/Controllers/LocationController.php new file mode 100644 index 0000000..92af4c5 --- /dev/null +++ b/skolehjem/app/Http/Controllers/LocationController.php @@ -0,0 +1,133 @@ +middleware([ "auth" ]); + + $this->middleware([ "check.auth:locations.list" ])->only("index"); + $this->middleware([ "check.auth:locations.show" ])->only("show"); + $this->middleware([ "check.auth:locations.create" ])->only("create", "store"); + $this->middleware([ "check.auth:locations.edit" ])->only("edit", "update"); + $this->middleware([ "check.auth:locations.delete" ])->only("delete"); + } + + /** + * Display a listing of the resource. + * + * @param Request $request + * @return \Illuminate\Http\Response + */ + public function index(Request $request) + { + $locations = Location::query()->paginate($request->input("limit", 20)); + + return Response::detect("locations.index", [ "locations" => $locations ]); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return Response::detect("locations.create"); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $data = $request->validate([ + "name" => "required", + ]); + + $location = new Location($data); + + $locations = Location::query()->where('name', '=', $request->name)->get(); + + // If there already is a washing machine with that name, then don't add it + if (count($locations) > 0) + return redirect()->route("locations.store")->with('NameExists', '

Der findes allerede en lokation med det navn!

'); + else { // Else - Add it + $location->save(); + $locations = Location::query()->paginate($request->input("limit", 20)); + return redirect()->route("locations.index", ['locations' => $locations]); + } + } + + /** + * Display the specified resource. + * + * @param \App\Location $location + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function show(Location $location) + { + return view("admin.locations.show", [ "location" => $location]); + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\Location $location + * @return \Illuminate\Http\Response + */ + public function edit(Location $location) + { + return Response::detect("locations.edit", [ "location" => $location] ); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\Location $location + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $data = $request->validate([ + "name" => "required", + ]); + + $location = Location::find($id); + + + $allMachines = Location::query()->where('name', '=', $request->name)->where('id', '!=', $id)->get(); + + // If there already is a washing machine with that name, then don't change it + if (count($allMachines) > 0) + return redirect()->route("locations.store")->with('NameExists', '

Der findes allerede en lokation med det navn!

'); + else { // Else - Change the name + $location->update($data); + $location->save(); + + $locations = Location::query()->paginate($request->input("limit", 20)); + return redirect()->route("locations.index", ["locations" => $locations]); + } + } + + /** + * Remove the specified resource from storage. + * + * @param \App\Location $location + * @return \Illuminate\Http\Response + */ + public function destroy(Location $location) + { + + } +} diff --git a/skolehjem/app/Http/Controllers/NewsController.php b/skolehjem/app/Http/Controllers/NewsController.php new file mode 100644 index 0000000..2586ef1 --- /dev/null +++ b/skolehjem/app/Http/Controllers/NewsController.php @@ -0,0 +1,116 @@ +middleware([ "auth" ]); + + $this->middleware([ "check.auth:news.list" ])->only("index"); + $this->middleware([ "check.auth:news.show" ])->only("show"); + $this->middleware([ "check.auth:news.create" ])->only("create", "store"); + $this->middleware([ "check.auth:news.edit" ])->only("edit", "update"); + $this->middleware([ "check.auth:news.delete" ])->only("delete"); + } + + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\Response + */ + public function index(Request $request) + { + $news = News::query()->paginate($request->input("limit", 20)); + + return Response::detect("news.index", [ "news" => $news ]); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return Response::detect("news.create"); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\RedirectResponse + */ + public function store(Request $request) + { + $data = $request->validate([ + "name" => "required", + "content" => "required" + ]); + + $news = new News($data); + $news->save(); + + return redirect()->route("news.index"); + } + + /** + * Display the specified resource. + * + * @param \App\News $news + * @return \Illuminate\Http\Response + */ + public function show(News $news) + { + // + } + + /** + * Show the form for editing the specified resource. + * + * @param \App\News $news + * @return \Illuminate\Http\Response + */ + public function edit(News $news) + { + return Response::detect("news.edit", [ "news" => $news ]); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param \App\News $news + * @return \Illuminate\Http\RedirectResponse + */ + public function update(Request $request, News $news) + { + $data = $request->validate([ + "name" => "required", + "content" => "required" + ]); + + $news->update($data); + + return redirect()->route("news.index"); + } + + /** + * Remove the specified resource from storage. + * + * @param \App\News $news + * @return \Illuminate\Http\RedirectResponse + * @throws \Exception + */ + public function destroy(News $news) + { + $news->delete(); + return redirect()->route("news.index"); + } +} diff --git a/skolehjem/app/Http/Controllers/UserController.php b/skolehjem/app/Http/Controllers/UserController.php index 13b09b8..c9964df 100644 --- a/skolehjem/app/Http/Controllers/UserController.php +++ b/skolehjem/app/Http/Controllers/UserController.php @@ -53,7 +53,6 @@ class UserController extends Controller { $roles = Role::all(); return Response::detect("users.create", ['roles' => $roles]); - } /** @@ -169,9 +168,7 @@ class UserController extends Controller } $users = User::query()->paginate(20); - return Response::detect("users.index", [ - "users" => $users - ]); + return redirect()->route("users.index"); } /** @@ -309,9 +306,7 @@ class UserController extends Controller } $users = User::query()->paginate(20); - return Response::detect("users.index", [ - "users" => $users - ]); + return redirect()->route("users.index"); } public function search(Request $request){ diff --git a/skolehjem/app/Http/Controllers/WashingMachineController.php b/skolehjem/app/Http/Controllers/WashingMachineController.php index 07b1940..9ef3096 100644 --- a/skolehjem/app/Http/Controllers/WashingMachineController.php +++ b/skolehjem/app/Http/Controllers/WashingMachineController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Location; use App\WashingReservation; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; @@ -44,7 +45,9 @@ class WashingMachineController extends Controller */ public function create() { - return Response::detect("washing-machines.create"); + $locations = Location::all(); + + return Response::detect("washing-machines.create", ["locations" => $locations] ); } /** @@ -56,12 +59,13 @@ class WashingMachineController extends Controller public function store(Request $request) { $data = $request->validate([ - "name" => "required" + "name" => "required", + "location_id" => "required" ]); $machine = new WashingMachine($data); - $allMachines = WashingMachine::query()->where('name', '=', $request->name)->get(); + $allMachines = WashingMachine::query()->where('name', '=', $request->name)->where('location_id', "=", $request->location_id)->get(); // If there already is a washing machine with that name, then don't add it if (count($allMachines) > 0) @@ -81,11 +85,7 @@ class WashingMachineController extends Controller */ public function show($id) { - $machine = WashingMachine::find($id); - return Response::detect("washing-machines.show", [ - "machine" => $machine - ]); } /** @@ -97,9 +97,11 @@ class WashingMachineController extends Controller public function edit($id) { $machine = WashingMachine::find($id); + $locations = Location::all(); return Response::detect("washing-machines.edit", [ - "machine" => $machine + "machine" => $machine, + "locations" => $locations ]); } @@ -113,13 +115,14 @@ class WashingMachineController extends Controller public function update(Request $request, $id) { $data = $request->validate([ - "name" => "required" + "name" => "required", + "location_id" => "required", ]); $machine = WashingMachine::find($id); - $allMachines = WashingMachine::query()->where('name', '=', $request->name)->where('id', '!=', $id)->get(); + $allMachines = WashingMachine::query()->where('name', '=', $request->name)->where('location_id', "=", $request->location_id)->where('id', '!=', $id)->get(); // If there already is a washing machine with that name, then don't change it if (count($allMachines) > 0) diff --git a/skolehjem/app/Http/Controllers/WashingReservationController.php b/skolehjem/app/Http/Controllers/WashingReservationController.php index afbcf38..11c77a5 100644 --- a/skolehjem/app/Http/Controllers/WashingReservationController.php +++ b/skolehjem/app/Http/Controllers/WashingReservationController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Location; use App\WashingMachine; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; @@ -103,10 +104,7 @@ class WashingReservationController extends Controller */ public function edit($id) { - $reservation = WashingReservation::query()->find($id); - $machines = WashingMachine::all(); - return Response::detect("washing-reservations.edit", ['washing_reservation' => $reservation, 'machines' => $machines ]); } /** @@ -118,26 +116,7 @@ class WashingReservationController extends Controller */ public function update(Request $request, $id) { - $data = $request->validate([ - "time" => "required", - "machine" => "required" - ]); - $machineReservation = WashingReservation::find($id); - - $machineReservation->update($data); - - $saved = $machineReservation->save(); - - if(!$saved){ - return Response::detect("washing-reservations.update", [ - "washing_reservation" => $machineReservation - ]); - }else{ - $reservations = WashingReservation::query()->paginate($request->query("limit", 20)); - - return Response::detect("washing-reservations.index", [ "reservations" => $reservations]); - } } /** @@ -164,10 +143,13 @@ class WashingReservationController extends Controller $date = $request->date; $datetext = $request->datetext; - $machines = WashingMachine::all(); + if($request->location_id == 0) + $request->location_id = Location::all()->first()->id; + + $machines = WashingMachine::query()->where("location_id", "=", $request->location_id)->orderBy("name", "asc")->get(); if($request->machine_id == 0) - $request->machine_id = WashingMachine::all()->first()->id; + $request->machine_id = WashingMachine::query()->orderBy("name", "asc")->first()->id; $reservations = WashingReservation::query()->where("machine_id", "=", $request->machine_id)->where("time", "LIKE", $datetext."%")->get(); @@ -177,7 +159,9 @@ class WashingReservationController extends Controller array_push($times, $reservation->time); } - $output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times ]); + $locations = Location::query()->orderBy("name", "asc")->get(); + + $output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times, "locations" => $locations ]); return Response($output); } } @@ -246,4 +230,3 @@ class WashingReservationController extends Controller return Response::detect("washing-reservations.index", [ "reservations" => $reservations]); } } - diff --git a/skolehjem/app/Location.php b/skolehjem/app/Location.php new file mode 100644 index 0000000..75056e0 --- /dev/null +++ b/skolehjem/app/Location.php @@ -0,0 +1,12 @@ +id(); + $table->string("name")->unique(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('locations'); + } +} diff --git a/skolehjem/database/migrations/2020_06_08_073954_create_washing_machines.php b/skolehjem/database/migrations/2020_06_08_073954_create_washing_machines.php index 8b9ded4..10d4b50 100644 --- a/skolehjem/database/migrations/2020_06_08_073954_create_washing_machines.php +++ b/skolehjem/database/migrations/2020_06_08_073954_create_washing_machines.php @@ -17,8 +17,11 @@ class CreateWashingMachines extends Migration { Schema::create('washing_machines', function (Blueprint $table) { $table->id(); - $table->string("name")->unique(); + $table->string("name"); + + $table->foreignId("location_id")->constrained("locations", "id"); $table->timestamps(); + $table->unique(['name', 'location_id']); }); } diff --git a/skolehjem/database/migrations/2020_08_06_092000_create_news_table.php b/skolehjem/database/migrations/2020_08_06_092000_create_news_table.php new file mode 100644 index 0000000..7d6abc8 --- /dev/null +++ b/skolehjem/database/migrations/2020_08_06_092000_create_news_table.php @@ -0,0 +1,33 @@ +id(); + $table->string("name"); + $table->text("content"); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('news'); + } +} diff --git a/skolehjem/database/seeds/ContactSeeder.php b/skolehjem/database/seeds/ContactSeeder.php index 2b289be..b63d9e9 100644 --- a/skolehjem/database/seeds/ContactSeeder.php +++ b/skolehjem/database/seeds/ContactSeeder.php @@ -30,28 +30,28 @@ class ContactSeeder extends Seeder 'contactname' => "Thomas Thomsen", 'email' => "thth@sde.dk", 'title' => "Kollegieassistent", - 'phone' => "24629450", + 'phone' => "", 'phonetimes' => "", ], [ 'contactname' => "Anja Holm Brix", 'email' => "ahb@sde.dk", 'title' => "Kollegieassistent", - 'phone' => "24629450", + 'phone' => "", 'phonetimes' => "", ], [ 'contactname' => "Britta Overgaard Brink Olsen", 'email' => "brio@sde.dk", 'title' => "Kollegieassistent", - 'phone' => "24629450", + 'phone' => "", 'phonetimes' => "", ], [ 'contactname' => "Jesper Sandberg", 'email' => "jesa@sde.dk", 'title' => "Kollegieassistent", - 'phone' => "24629450", + 'phone' => "", 'phonetimes' => "", ], ]; diff --git a/skolehjem/database/seeds/DatabaseSeeder.php b/skolehjem/database/seeds/DatabaseSeeder.php index b099698..dfd923b 100644 --- a/skolehjem/database/seeds/DatabaseSeeder.php +++ b/skolehjem/database/seeds/DatabaseSeeder.php @@ -15,5 +15,6 @@ class DatabaseSeeder extends Seeder $this->call(RoleSeeder::class); $this->call(UserSeeder::class); $this->call(ContactSeeder::class); + $this->call(LocationSeeder::class); } } diff --git a/skolehjem/database/seeds/LocationSeeder.php b/skolehjem/database/seeds/LocationSeeder.php new file mode 100644 index 0000000..e1250f7 --- /dev/null +++ b/skolehjem/database/seeds/LocationSeeder.php @@ -0,0 +1,31 @@ + "Bygning B" + ], + [ + "name" => "Bygning E" + ] + ]; + + foreach ($locationdata as $data) { + $location = new \App\Location(); + + $location->name = $data["name"]; + + $location->save(); + } + } +} diff --git a/skolehjem/database/seeds/PermissionSeeder.php b/skolehjem/database/seeds/PermissionSeeder.php index fb01e2a..db58e11 100644 --- a/skolehjem/database/seeds/PermissionSeeder.php +++ b/skolehjem/database/seeds/PermissionSeeder.php @@ -25,7 +25,7 @@ class PermissionSeeder extends Seeder "ownuser.edit" => "Allows editing of your own user", /** - * The CALENDAR specific permissions + * The CALENDAR specific permissions //TODO: Do we use them? */ "calendar.create" => "Create a new event.", "calendar.list" => "Shows all events.", @@ -51,63 +51,118 @@ class PermissionSeeder extends Seeder "event.edit" => "Allows editing of events", "event.delete" => "Allows deletion of events", + /** + * The CONTACT specific permissions + */ "contact.create" => "Creates a new contact", "contact.list" => "Shows all contacts", "contact.show" => "Shows a specific contact", "contact.edit" => "allows editing of contacts", "contact.delete" => "Allows deletion of contacts", + /** + * The FEEDBACK specific permissions + */ "feedback.create" => "Creates a new feedback message", "feedback.list" => "Shows all feedback messages", "feedback.show" => "Shows a specific feedback message", "feedback.edit" => "allows editing of feedback messages", "feedback.delete" => "allows deletion of feedback messages", + /** + * The MENUPLAN specific permissions + */ "menuplan.create" => "Create a new menuplan", "menuplan.list" => "Shows all menuplans", "menuplan.show" => "Shows a specific menuplan", "menuplan.edit" => "Allows editing of menuplans", "menuplan.delete" => "Allows deletion of menuplans", + /** + * The RESOURCE CATEGORY specific permissions + */ "resource.category.create" => "Create a new resource category", "resource.category.list" => "Shows all resource categories", "resource.category.show" => "Shows a specific resource category", "resource.category.edit" => "Allows editing of resource categories", "resource.category.delete" => "Allows deletion of resource categories", + /** + * The RESOURCE EXTENSION specific permissions + */ "resource.extension.create" => "Create a new resource extension", "resource.extension.list" => "Shows all resource extensions", "resource.extension.show" => "Shows a specific resource extension", "resource.extension.edit" => "Allows editing of resource extensions", "resource.extension.delete" => "Allows deletion of resource extensions", + /** + * The RESOURCE specific permissions + */ "resource.create" => "Create a new resource", "resource.list" => "Shows all resources", "resource.show" => "Shows a specific resource", "resource.edit" => "Allows editing of resources", "resource.delete" => "Allows deletion of resources", + /** + * The WASHING MACHINE specific permissions + */ "washing.machine.create" => "Create a new washing machine", "washing.machine.list" => "Shows all washing machines", "washing.machine.show" => "Shows a specific washing machine", "washing.machine.edit" => "Allows editing of washing machines", "washing.machine.delete" => "Allows deletion of washing machines", + /** + * The WASHING MACHINE RESERVATION specific permissions + */ "washing.machine.reservation.create" => "Create a new washing machine reservation", "washing.machine.reservation.list" => "Shows all washing machine reservations", "washing.machine.reservation.show" => "Shows a specific washing machine reservation", "washing.machine.reservation.edit" => "Allows editing of washing machine reservations", "washing.machine.reservation.delete" => "Allows deletion of washing machine reservations", + /** + * The ROLES specific permissions + */ "roles.create" => "Create a new role", "roles.list" => "Shows all roles", "roles.show" => "Shows a specific role", "roles.edit" => "Allows editing of roles", "roles.delete" => "Allows deletion of roles", - //Allows access to the admin panel - "admin.panel.show" => "Allows access to administration panel", + /** + * The GUIDE specific permissions + */ + "guides.create" => "Create a new guide", + "guides.list" => "Shows all guides", + "guides.show" => "Shows a specific guide", + "guides.edit" => "Allows editing of guides", + "guides.delete" => "Allows deletion of guides", + /** + * The LOCATION specific permissions + */ + "locations.create" => "Create a new location", + "locations.list" => "Shows all locations", + "locations.show" => "Shows a specific location", + "locations.edit" => "Allows editing of locations", + "locations.delete" => "Allows deletion of locations", + + /** + * The NEWS specific permissions + */ + "news.create" => "Create a new location", + "news.list" => "Shows all locations", + "news.show" => "Shows a specific location", + "news.edit" => "Allows editing of locations", + "news.delete" => "Allows deletion of locations", + + /** + * The ADMIN PANEL specific permissions + */ + "admin.panel.show" => "Allows access to administration panel", ]; foreach ($permissions as $key => $value) { diff --git a/skolehjem/resources/views/admin/contacts/create.blade.php b/skolehjem/resources/views/admin/contacts/create.blade.php index 947c007..243d360 100644 --- a/skolehjem/resources/views/admin/contacts/create.blade.php +++ b/skolehjem/resources/views/admin/contacts/create.blade.php @@ -27,7 +27,7 @@ - + diff --git a/skolehjem/resources/views/admin/contacts/edit.blade.php b/skolehjem/resources/views/admin/contacts/edit.blade.php index afc0a5a..acaf58d 100644 --- a/skolehjem/resources/views/admin/contacts/edit.blade.php +++ b/skolehjem/resources/views/admin/contacts/edit.blade.php @@ -28,7 +28,7 @@ - + diff --git a/skolehjem/resources/views/admin/events/index.blade.php b/skolehjem/resources/views/admin/events/index.blade.php index 9ce8a1c..6d18017 100644 --- a/skolehjem/resources/views/admin/events/index.blade.php +++ b/skolehjem/resources/views/admin/events/index.blade.php @@ -25,7 +25,7 @@ Event Navn Event Ansvarlig Event Dato - Update + Show Update Delete @@ -34,7 +34,7 @@ {{ $event->name }} {{ $event->accountable }} {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($event->date))->format('d/m/Y \k\l\. H:i') }} - $event ]) }}">Update + $event ]) }}">Show $event ]) }}">Update
$event ]) }}" class="w-100 nostyle"> @csrf diff --git a/skolehjem/resources/views/admin/layout/base.blade.php b/skolehjem/resources/views/admin/layout/base.blade.php index 554104c..ada4d1c 100644 --- a/skolehjem/resources/views/admin/layout/base.blade.php +++ b/skolehjem/resources/views/admin/layout/base.blade.php @@ -17,12 +17,18 @@

Roller

+
+

Nyheder

+

Menuplan

Aktiviteter

+
+

Lokationer

+

Vaskemaskiner

diff --git a/skolehjem/resources/views/admin/locations/create.blade.php b/skolehjem/resources/views/admin/locations/create.blade.php new file mode 100644 index 0000000..eed7c55 --- /dev/null +++ b/skolehjem/resources/views/admin/locations/create.blade.php @@ -0,0 +1,20 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Opret Lokation +@endsection + +@section("path") + Opret Lokation / +@endsection + +@section("content") +

Opret Lokation

+ + @csrf + + + +
+@endsection diff --git a/skolehjem/resources/views/admin/locations/delete.blade.php b/skolehjem/resources/views/admin/locations/delete.blade.php new file mode 100644 index 0000000..cf31266 --- /dev/null +++ b/skolehjem/resources/views/admin/locations/delete.blade.php @@ -0,0 +1,13 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Vejledning - Fjern +@endsection + +@section("path") + Fjern Guide / +@endsection + +@section("content") +@endsection diff --git a/skolehjem/resources/views/admin/locations/edit.blade.php b/skolehjem/resources/views/admin/locations/edit.blade.php new file mode 100644 index 0000000..b0d8dfd --- /dev/null +++ b/skolehjem/resources/views/admin/locations/edit.blade.php @@ -0,0 +1,21 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Lokation - Rediger +@endsection + +@section("path") + Rediger lokation / +@endsection + +@section("content") +

Rediger Lokation

+
$location ]) }}"> + @csrf + @method("put") + + + +
+@endsection diff --git a/skolehjem/resources/views/admin/locations/index.blade.php b/skolehjem/resources/views/admin/locations/index.blade.php new file mode 100644 index 0000000..ac1f6af --- /dev/null +++ b/skolehjem/resources/views/admin/locations/index.blade.php @@ -0,0 +1,40 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Vis Lokationer +@endsection + +@section("path") + Vis lokationer / +@endsection + +@section("content") +
+ CreateOpret Lokation +
+ + + + + + + + @foreach($locations as $location) + + + + + + + @endforeach +
NavnShowUpdateDelete
{{$location->name}} $location ]) }}">Show $location ]) }}">Update
$location ]) }}" class="w-100 nostyle"> + @csrf + @method("delete") + + +
+
+ + {{ $locations->links() }} +@endsection diff --git a/skolehjem/resources/views/admin/locations/show.blade.php b/skolehjem/resources/views/admin/locations/show.blade.php new file mode 100644 index 0000000..11f7d09 --- /dev/null +++ b/skolehjem/resources/views/admin/locations/show.blade.php @@ -0,0 +1,43 @@ + + + + @yield("title") + + + + + + +
+ Syddansk Erhvervsskole +

Lokation: {{ $location->name }}

+
+
+ +
+ @foreach(\App\WashingMachine::query()->where("location_id", "=", $location->id)->get() as $machine) + @foreach(\App\WashingReservation::query()->where("machine_id", "=", $machine->id)->where("time", "LIKE", date("Y-m-d"). "%")->orderBy("time", "asc")->get() as $reservation) + @if($i % 3 == 1) +
+
+ @endif +
+

{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}

+
+ Dato: {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y') }} + Tid: {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('\k\l\. H:i') }} - {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_first }} {{ \App\User::query()->where("id", "=", $reservation->user_id)->first()->name_last }} +
+
+ + @endforeach + @endforeach + @if($i == 1) + Der er ingen vaskemaskine reservationer for i dag. + @endif +
+
+ + +@yield("scripts") + + diff --git a/skolehjem/resources/views/admin/locations/store.blade.php b/skolehjem/resources/views/admin/locations/store.blade.php new file mode 100644 index 0000000..239ca01 --- /dev/null +++ b/skolehjem/resources/views/admin/locations/store.blade.php @@ -0,0 +1,14 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Vejledning - Opret +@endsection + +@section("path") + Opret vejledning / +@endsection + +@section("content") + vejledning blev (ikke) oprettet. +@endsection diff --git a/skolehjem/resources/views/admin/locations/update.blade.php b/skolehjem/resources/views/admin/locations/update.blade.php new file mode 100644 index 0000000..4b9788d --- /dev/null +++ b/skolehjem/resources/views/admin/locations/update.blade.php @@ -0,0 +1,14 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Vejledning - Rediger +@endsection + +@section("path") + $link]) }}" class="text-white">Vejledning / +@endsection + +@section("content") + Din vejledning blev (ikke) redigeret. +@endsection diff --git a/skolehjem/resources/views/admin/news/create.blade.php b/skolehjem/resources/views/admin/news/create.blade.php new file mode 100644 index 0000000..af4ed94 --- /dev/null +++ b/skolehjem/resources/views/admin/news/create.blade.php @@ -0,0 +1,41 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Opret Nyheder +@endsection + +@section("path") + Opret Nyheder / +@endsection + +@section("content") + + +

Opret Nyhed

+
+ @csrf + + + + +
+ + + + + +@endsection diff --git a/skolehjem/resources/views/admin/news/delete.blade.php b/skolehjem/resources/views/admin/news/delete.blade.php new file mode 100644 index 0000000..cf31266 --- /dev/null +++ b/skolehjem/resources/views/admin/news/delete.blade.php @@ -0,0 +1,13 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Vejledning - Fjern +@endsection + +@section("path") + Fjern Guide / +@endsection + +@section("content") +@endsection diff --git a/skolehjem/resources/views/admin/news/edit.blade.php b/skolehjem/resources/views/admin/news/edit.blade.php new file mode 100644 index 0000000..fbf37a3 --- /dev/null +++ b/skolehjem/resources/views/admin/news/edit.blade.php @@ -0,0 +1,46 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Nyhed - Rediger +@endsection + +@section("path") + Rediger nyhed / +@endsection + +@section("content") + + +

Rediger nyhed:

+
$news])}}"> + @csrf + @method("PUT") + + + + +
+ + +@endsection diff --git a/skolehjem/resources/views/admin/news/index.blade.php b/skolehjem/resources/views/admin/news/index.blade.php new file mode 100644 index 0000000..797c725 --- /dev/null +++ b/skolehjem/resources/views/admin/news/index.blade.php @@ -0,0 +1,38 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Opret Nyhed +@endsection + +@section("path") + Opret Nyheder / +@endsection + +@section("content") +
+ CreateOpret Nyheder +
+ + + + + + + @foreach($news as $new) + + + + + + @endforeach +
NavnUpdateDelete
{{$new->name}} $new ]) }}">Update
$new ]) }}" class="w-100 nostyle"> + @csrf + @method("delete") + + +
+
+ + {{ $news->links() }} +@endsection diff --git a/skolehjem/resources/views/admin/news/store.blade.php b/skolehjem/resources/views/admin/news/store.blade.php new file mode 100644 index 0000000..239ca01 --- /dev/null +++ b/skolehjem/resources/views/admin/news/store.blade.php @@ -0,0 +1,14 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Vejledning - Opret +@endsection + +@section("path") + Opret vejledning / +@endsection + +@section("content") + vejledning blev (ikke) oprettet. +@endsection diff --git a/skolehjem/resources/views/admin/news/update.blade.php b/skolehjem/resources/views/admin/news/update.blade.php new file mode 100644 index 0000000..4b9788d --- /dev/null +++ b/skolehjem/resources/views/admin/news/update.blade.php @@ -0,0 +1,14 @@ +@extends("admin.layout.base") +@extends("admin.layout.header") + +@section("title") + Vejledning - Rediger +@endsection + +@section("path") + $link]) }}" class="text-white">Vejledning / +@endsection + +@section("content") + Din vejledning blev (ikke) redigeret. +@endsection diff --git a/skolehjem/resources/views/admin/users/edit.blade.php b/skolehjem/resources/views/admin/users/edit.blade.php index 17b2ed3..d32f68c 100644 --- a/skolehjem/resources/views/admin/users/edit.blade.php +++ b/skolehjem/resources/views/admin/users/edit.blade.php @@ -56,8 +56,7 @@ @endforeach @endif - - + @endsection diff --git a/skolehjem/resources/views/admin/users/forgot.blade.php b/skolehjem/resources/views/admin/users/forgot.blade.php index 20dc1fa..ae29260 100644 --- a/skolehjem/resources/views/admin/users/forgot.blade.php +++ b/skolehjem/resources/views/admin/users/forgot.blade.php @@ -13,7 +13,7 @@ @csrf + - {!! session()->get("errornosuchuser") !!} @endsection diff --git a/skolehjem/resources/views/admin/washing-machines/create.blade.php b/skolehjem/resources/views/admin/washing-machines/create.blade.php index c81e7c9..c7e2191 100644 --- a/skolehjem/resources/views/admin/washing-machines/create.blade.php +++ b/skolehjem/resources/views/admin/washing-machines/create.blade.php @@ -15,6 +15,17 @@ @csrf + + @endsection diff --git a/skolehjem/resources/views/admin/washing-machines/edit.blade.php b/skolehjem/resources/views/admin/washing-machines/edit.blade.php index 7e080d5..0f1ca12 100644 --- a/skolehjem/resources/views/admin/washing-machines/edit.blade.php +++ b/skolehjem/resources/views/admin/washing-machines/edit.blade.php @@ -15,6 +15,16 @@ @method("put") + @endsection diff --git a/skolehjem/resources/views/admin/washing-machines/index.blade.php b/skolehjem/resources/views/admin/washing-machines/index.blade.php index 3d06030..f8332da 100644 --- a/skolehjem/resources/views/admin/washing-machines/index.blade.php +++ b/skolehjem/resources/views/admin/washing-machines/index.blade.php @@ -17,12 +17,14 @@ + @foreach($machines as $machine) +
NavnLokation Update Delete
{{$machine->name}}{{\App\Location::query()->where("id", "=", $machine->location_id)->first()->name}} Update
@csrf diff --git a/skolehjem/resources/views/app/contacts/index.blade.php b/skolehjem/resources/views/app/contacts/index.blade.php index c5e39df..50a2741 100644 --- a/skolehjem/resources/views/app/contacts/index.blade.php +++ b/skolehjem/resources/views/app/contacts/index.blade.php @@ -15,8 +15,10 @@

Telefontid:

{!! $contact->phonetimes !!} @endif - +45 {{ chunk_split($contact->phone, 2, ' ') }} - Ring + @if($contact->phone) + +45 {{ chunk_split($contact->phone, 2, ' ') }} + Ring + @endif @endforeach @else

Der er ingen kontakter!

diff --git a/skolehjem/resources/views/app/feedbacks/create.blade.php b/skolehjem/resources/views/app/feedbacks/create.blade.php index 766e94e..7d6cdbf 100644 --- a/skolehjem/resources/views/app/feedbacks/create.blade.php +++ b/skolehjem/resources/views/app/feedbacks/create.blade.php @@ -13,7 +13,7 @@ - +
diff --git a/skolehjem/resources/views/app/news/index.blade.php b/skolehjem/resources/views/app/news/index.blade.php new file mode 100644 index 0000000..781ad69 --- /dev/null +++ b/skolehjem/resources/views/app/news/index.blade.php @@ -0,0 +1,69 @@ + + + + @yield("title") + + + + + + + +
+ @foreach(\App\News::query()->orderBy("created_at", "desc")->get() as $new) +

{{ $new->name }}

+ {!! $new->content !!} + @endforeach +
+ +@yield("scripts") + + diff --git a/skolehjem/resources/views/app/root/index.blade.php b/skolehjem/resources/views/app/root/index.blade.php index 4ea4a76..97376b0 100644 --- a/skolehjem/resources/views/app/root/index.blade.php +++ b/skolehjem/resources/views/app/root/index.blade.php @@ -1,70 +1 @@ -{{----}} -{{------app -{{----}} - -{{--Index--}} -{{----}}@extends("app.users.index") - -{{--Login--}} -{{--@extends("app.users.login")--}} - -{{--Register--}} -{{--@extends("app.users.register")--}} - -{{--Events--}} -{{--@extends("app.events.index")--}} - -{{--Vagttelefon--}} -{{--@extends("app.vagttelefons.index")--}} - -{{--Booking Liste--}} -{{--@extends("app.washing-reservations.index")--}} - -{{--Menuplan--}} -{{--@extends("app.menuplans.index")--}} - -{{--Contact--}} -{{--@extends("app.contact.index")--}} - -{{--Account--}} -{{--@extends("app.users.index")--}} - -{{--Feedback--}} -{{--@extends("app.feedbacks.index")--}} - -{{----}} -{{------Admin Panel -{{----}} - -{{--Index--}} -{{--@extends("admin.index")--}} - -{{--Create User--}} -{{--@extends("admin.users.create")--}} - -{{--Read User--}} -{{--@extends("admin.users.show")--}} - -{{--Update User--}} -{{--@extends("admin.users.update")--}} - -{{--Create Menuplan--}} -{{--@extends("admin.menuplans.create")--}} - -{{--Read Menuplan--}} -{{--@extends("admin.menuplans.show")--}} - -{{--Update Menuplan--}} -{{--@extends("admin.menuplans.update")--}} - -{{--Create booking--}} -{{--@extends("admin.washing-reservations.create")--}} - -{{--Read booking--}} -{{--@extends("admin.washing-reservations.show")--}} - -{{--Create washing-machine--}} -{{--@extends("admin.washing-machines.create")--}} - -{{--Read washing-machine--}} -{{--@extends("admin.washing-machines.show")--}} +@extends("app.news.index") diff --git a/skolehjem/resources/views/app/users/forgot.blade.php b/skolehjem/resources/views/app/users/forgot.blade.php index 286ff7b..20b0f85 100644 --- a/skolehjem/resources/views/app/users/forgot.blade.php +++ b/skolehjem/resources/views/app/users/forgot.blade.php @@ -13,6 +13,7 @@ @csrf + @endsection diff --git a/skolehjem/resources/views/app/washing-reservations/create.blade.php b/skolehjem/resources/views/app/washing-reservations/create.blade.php index 6bf7bd4..fafdc9a 100644 --- a/skolehjem/resources/views/app/washing-reservations/create.blade.php +++ b/skolehjem/resources/views/app/washing-reservations/create.blade.php @@ -97,8 +97,8 @@ } function onDateSelect(date, dayHolder, datetext) { - console.log("Opdaterer selects"); let events; + let locationz; let machinez; let buttonz; @@ -114,20 +114,47 @@ dayHolder.classList.add("selected"); let machine_id; + let location_id; if(document.getElementById('washing-machines')) machine_id = document.getElementById('washing-machines').value; else machine_id = 0; + if(document.getElementById('locations')) + location_id = document.getElementById('locations').value; + else + location_id = 0; + axios({ method: 'get', url: '{{ route("washing-reservations.api") }}', - params: { 'date': date, 'machine_id': machine_id, 'datetext': datetext } + params: { 'date': date, 'machine_id': machine_id, 'datetext': datetext, 'location_id': location_id } }).then(function (response) { - console.log(response.data["unavailable_times"]); var data = response.data; + + if(document.getElementById("locations") != undefined) + locationz = document.getElementById("locations"); + else { + let span = document.createElement("span"); + span.classList.add("events__title"); + span.innerText = "Lokation"; + + let select = document.createElement("select"); + select.classList.add("events__title"); + select.id = "locations"; + select.name = "location_id"; + + select.onchange = function() { + onDateSelect(date, dayHolder, datetext); + } + + container.appendChild(span); + container.appendChild(select); + + locationz = document.getElementById("locations"); + } if(document.getElementById("washing-machines") != undefined) machinez = document.getElementById("washing-machines"); else { @@ -180,6 +207,24 @@ buttonz = document.getElementById("events"); } + let locations = data["locations"]; + + locationz.innerHTML = ""; + locationz.onchange = function () { + onDateSelect(date, dayHolder, datetext); + } + + for (let i = 0; i < locations.length; i++) { + let option = document.createElement("option"); + option.text = locations[i]["name"]; + option.value = locations[i]["id"]; + + if(location_id == locations[i]["id"]) + option.selected = "selected"; + + locationz.appendChild(option); + } + let machines = data["washingmachines"]; machinez.innerHTML = ""; @@ -213,7 +258,6 @@ let unavailable_times = data["unavailable_times"]; unavailable_times.forEach(function (item, index) { - console.log(item); document.getElementById(item).remove(); }); diff --git a/skolehjem/routes/web.php b/skolehjem/routes/web.php index 11b2bac..608c709 100644 --- a/skolehjem/routes/web.php +++ b/skolehjem/routes/web.php @@ -54,3 +54,5 @@ Route::resource("resource-extensions", "ResourceExtensionController"); Route::resource("resource-categories", "ResourceCategoryController"); Route::resource("roles", "RolesController"); Route::resource("guides", "GuideController"); +Route::resource("locations", "LocationController"); +Route::resource("news", "NewsController");