This commit is contained in:
victor 2020-07-29 13:33:20 +02:00
commit a779b7325d
21 changed files with 818 additions and 146 deletions

View File

@ -2518,6 +2518,487 @@
"headNameLabel": { "headNameLabel": {
"$ref": "AAAAAAFyktFfi0G3a2o=" "$ref": "AAAAAAFyktFfi0G3a2o="
} }
},
{
"_type": "RectangleView",
"_id": "AAAAAAFzmS7LcWMLwXs=",
"_parent": {
"$ref": "AAAAAAFyJv8bdYmeyX0="
},
"font": "Arial;13;0",
"left": 1128,
"top": 288,
"width": 937,
"height": 225
},
{
"_type": "UMLTextView",
"_id": "AAAAAAFzmS8SCGMPFm8=",
"_parent": {
"$ref": "AAAAAAFyJv8bdYmeyX0="
},
"font": "Arial;13;0",
"left": 1160,
"top": 304,
"width": 60,
"height": 25,
"text": "Events"
},
{
"_type": "ERDEntityView",
"_id": "AAAAAAFzmS+aamMoovQ=",
"_parent": {
"$ref": "AAAAAAFyJv8bdYmeyX0="
},
"model": {
"$ref": "AAAAAAFzmS+aamMmKco="
},
"subViews": [
{
"_type": "LabelView",
"_id": "AAAAAAFzmS+aamMp18A=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMoovQ="
},
"font": "Arial;13;1",
"left": 1144,
"top": 373,
"width": 195.45166015625,
"height": 13,
"text": "events"
},
{
"_type": "ERDColumnCompartmentView",
"_id": "AAAAAAFzmS+aamMqMjs=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMoovQ="
},
"model": {
"$ref": "AAAAAAFzmS+aamMmKco="
},
"subViews": [
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmS+hNmM1gqI=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMqMjs="
},
"model": {
"$ref": "AAAAAAFzmS+hAGMyFxQ="
},
"font": "Arial;13;0",
"left": 1149,
"top": 396,
"width": 185.45166015625,
"height": 13
},
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTAruGM/Lp8=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMqMjs="
},
"model": {
"$ref": "AAAAAAFzmTArgGM8P34="
},
"font": "Arial;13;0",
"left": 1149,
"top": 411,
"width": 185.45166015625,
"height": 13
},
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTKxaGNOze0=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMqMjs="
},
"model": {
"$ref": "AAAAAAFzmTKxMGNLYfU="
},
"font": "Arial;13;0",
"left": 1149,
"top": 426,
"width": 185.45166015625,
"height": 13
},
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTMsZ2NV6ug=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMqMjs="
},
"model": {
"$ref": "AAAAAAFzmTMsN2NSMr0="
},
"font": "Arial;13;0",
"left": 1149,
"top": 441,
"width": 185.45166015625,
"height": 13
}
],
"font": "Arial;13;0",
"left": 1144,
"top": 391,
"width": 195.45166015625,
"height": 68
}
],
"font": "Arial;13;0",
"left": 1144,
"top": 368,
"width": 195.45166015625,
"height": 91,
"nameLabel": {
"$ref": "AAAAAAFzmS+aamMp18A="
},
"columnCompartment": {
"$ref": "AAAAAAFzmS+aamMqMjs="
}
},
{
"_type": "ERDEntityView",
"_id": "AAAAAAFzmTUSMWOxglk=",
"_parent": {
"$ref": "AAAAAAFyJv8bdYmeyX0="
},
"model": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"subViews": [
{
"_type": "LabelView",
"_id": "AAAAAAFzmTUSMWOysPE=",
"_parent": {
"$ref": "AAAAAAFzmTUSMWOxglk="
},
"font": "Arial;13;1",
"left": 1488,
"top": 341,
"width": 176,
"height": 13,
"text": "user_events"
},
{
"_type": "ERDColumnCompartmentView",
"_id": "AAAAAAFzmTUSMWOzIXA=",
"_parent": {
"$ref": "AAAAAAFzmTUSMWOxglk="
},
"model": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"subViews": [
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTUsRWO/CkM=",
"_parent": {
"$ref": "AAAAAAFzmTUSMWOzIXA="
},
"model": {
"$ref": "AAAAAAFzmTUsD2O8Tv0="
},
"font": "Arial;13;0",
"left": 1493,
"top": 364,
"width": 166,
"height": 13
},
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTVGV2PGQ0M=",
"_parent": {
"$ref": "AAAAAAFzmTUSMWOzIXA="
},
"model": {
"$ref": "AAAAAAFzmTVGIWPD9D4="
},
"font": "Arial;13;0",
"left": 1493,
"top": 379,
"width": 166,
"height": 13
},
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTVY/GPNcbw=",
"_parent": {
"$ref": "AAAAAAFzmTUSMWOzIXA="
},
"model": {
"$ref": "AAAAAAFzmTVYxmPKgHI="
},
"font": "Arial;13;0",
"left": 1493,
"top": 394,
"width": 166,
"height": 13
}
],
"font": "Arial;13;0",
"left": 1488,
"top": 359,
"width": 176,
"height": 53
}
],
"font": "Arial;13;0",
"left": 1488,
"top": 336,
"width": 176,
"height": 96,
"nameLabel": {
"$ref": "AAAAAAFzmTUSMWOysPE="
},
"columnCompartment": {
"$ref": "AAAAAAFzmTUSMWOzIXA="
}
},
{
"_type": "ERDRelationshipView",
"_id": "AAAAAAFzmTidSGPovGU=",
"_parent": {
"$ref": "AAAAAAFyJv8bdYmeyX0="
},
"model": {
"$ref": "AAAAAAFzmTidSGPkITg="
},
"subViews": [
{
"_type": "EdgeLabelView",
"_id": "AAAAAAFzmTidSGPpLVU=",
"_parent": {
"$ref": "AAAAAAFzmTidSGPovGU="
},
"visible": false,
"font": "Arial;13;0",
"left": 1413,
"top": 379,
"height": 13,
"alpha": 1.5707963267948966,
"distance": 15,
"hostEdge": {
"$ref": "AAAAAAFzmTidSGPovGU="
},
"edgePosition": 1
},
{
"_type": "EdgeLabelView",
"_id": "AAAAAAFzmTidSGPqI+A=",
"_parent": {
"$ref": "AAAAAAFzmTidSGPovGU="
},
"font": "Arial;13;0",
"left": 1363,
"top": 379,
"height": 13,
"alpha": 0.5235987755982988,
"distance": 30,
"hostEdge": {
"$ref": "AAAAAAFzmTidSGPovGU="
},
"edgePosition": 2
},
{
"_type": "EdgeLabelView",
"_id": "AAAAAAFzmTidSWPrhLo=",
"_parent": {
"$ref": "AAAAAAFzmTidSGPovGU="
},
"font": "Arial;13;0",
"left": 1462,
"top": 379,
"height": 13,
"alpha": -0.5235987755982988,
"distance": 30,
"hostEdge": {
"$ref": "AAAAAAFzmTidSGPovGU="
}
}
],
"font": "Arial;13;0",
"head": {
"$ref": "AAAAAAFzmTUSMWOxglk="
},
"tail": {
"$ref": "AAAAAAFzmS+aamMoovQ="
},
"lineStyle": 2,
"points": "1338:400;1488:400",
"nameLabel": {
"$ref": "AAAAAAFzmTidSGPpLVU="
},
"tailNameLabel": {
"$ref": "AAAAAAFzmTidSGPqI+A="
},
"headNameLabel": {
"$ref": "AAAAAAFzmTidSWPrhLo="
}
},
{
"_type": "ERDEntityView",
"_id": "AAAAAAFzmTrFAGQbbu8=",
"_parent": {
"$ref": "AAAAAAFyJv8bdYmeyX0="
},
"model": {
"$ref": "AAAAAAFzmTrE/mQZtbU="
},
"subViews": [
{
"_type": "LabelView",
"_id": "AAAAAAFzmTrFAGQc1P0=",
"_parent": {
"$ref": "AAAAAAFzmTrFAGQbbu8="
},
"font": "Arial;13;1",
"left": 1784,
"top": 341,
"width": 208,
"height": 13,
"text": "users (find in user system)"
},
{
"_type": "ERDColumnCompartmentView",
"_id": "AAAAAAFzmTrFAGQdssg=",
"_parent": {
"$ref": "AAAAAAFzmTrFAGQbbu8="
},
"model": {
"$ref": "AAAAAAFzmTrE/mQZtbU="
},
"subViews": [
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTrWuWQpM6E=",
"_parent": {
"$ref": "AAAAAAFzmTrFAGQdssg="
},
"model": {
"$ref": "AAAAAAFzmTrWh2QmNU4="
},
"font": "Arial;13;0",
"left": 1789,
"top": 364,
"width": 198,
"height": 13
},
{
"_type": "ERDColumnView",
"_id": "AAAAAAFzmTr2rGQyAHE=",
"_parent": {
"$ref": "AAAAAAFzmTrFAGQdssg="
},
"model": {
"$ref": "AAAAAAFzmTr2eGQvxRY="
},
"font": "Arial;13;0",
"left": 1789,
"top": 379,
"width": 198,
"height": 13
}
],
"font": "Arial;13;0",
"left": 1784,
"top": 359,
"width": 208,
"height": 38
}
],
"font": "Arial;13;0",
"left": 1784,
"top": 336,
"width": 208,
"height": 73,
"nameLabel": {
"$ref": "AAAAAAFzmTrFAGQc1P0="
},
"columnCompartment": {
"$ref": "AAAAAAFzmTrFAGQdssg="
}
},
{
"_type": "ERDRelationshipView",
"_id": "AAAAAAFzmTtiuWR2PIU=",
"_parent": {
"$ref": "AAAAAAFyJv8bdYmeyX0="
},
"model": {
"$ref": "AAAAAAFzmTtiuWRye2I="
},
"subViews": [
{
"_type": "EdgeLabelView",
"_id": "AAAAAAFzmTtiuWR3x4k=",
"_parent": {
"$ref": "AAAAAAFzmTtiuWR2PIU="
},
"visible": false,
"font": "Arial;13;0",
"left": 1723,
"top": 347,
"height": 13,
"alpha": 1.5707963267948966,
"distance": 15,
"hostEdge": {
"$ref": "AAAAAAFzmTtiuWR2PIU="
},
"edgePosition": 1
},
{
"_type": "EdgeLabelView",
"_id": "AAAAAAFzmTtiuWR4U60=",
"_parent": {
"$ref": "AAAAAAFzmTtiuWR2PIU="
},
"font": "Arial;13;0",
"left": 1688,
"top": 347,
"height": 13,
"alpha": 0.5235987755982988,
"distance": 30,
"hostEdge": {
"$ref": "AAAAAAFzmTtiuWR2PIU="
},
"edgePosition": 2
},
{
"_type": "EdgeLabelView",
"_id": "AAAAAAFzmTtiuWR5oHg=",
"_parent": {
"$ref": "AAAAAAFzmTtiuWR2PIU="
},
"font": "Arial;13;0",
"left": 1758,
"top": 347,
"height": 13,
"alpha": -0.5235987755982988,
"distance": 30,
"hostEdge": {
"$ref": "AAAAAAFzmTtiuWR2PIU="
}
}
],
"font": "Arial;13;0",
"head": {
"$ref": "AAAAAAFzmTrFAGQbbu8="
},
"tail": {
"$ref": "AAAAAAFzmTUSMWOxglk="
},
"lineStyle": 2,
"points": "1663:368;1784:368",
"nameLabel": {
"$ref": "AAAAAAFzmTtiuWR3x4k="
},
"tailNameLabel": {
"$ref": "AAAAAAFzmTtiuWR4U60="
},
"headNameLabel": {
"$ref": "AAAAAAFzmTtiuWR5oHg="
}
} }
] ]
}, },
@ -3498,6 +3979,251 @@
"foreignKey": true "foreignKey": true
} }
] ]
},
{
"_type": "ERDEntity",
"_id": "AAAAAAFzmS9Y8GMUhJA=",
"_parent": {
"$ref": "AAAAAAFyJv8bdImdWmM="
},
"name": "Entity1"
},
{
"_type": "ERDEntity",
"_id": "AAAAAAFzmS+aamMmKco=",
"_parent": {
"$ref": "AAAAAAFyJv8bdImdWmM="
},
"name": "events",
"ownedElements": [
{
"_type": "ERDRelationship",
"_id": "AAAAAAFzmTidSGPkITg=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMmKco="
},
"end1": {
"_type": "ERDRelationshipEnd",
"_id": "AAAAAAFzmTidSGPlGys=",
"_parent": {
"$ref": "AAAAAAFzmTidSGPkITg="
},
"reference": {
"$ref": "AAAAAAFzmS+aamMmKco="
}
},
"end2": {
"_type": "ERDRelationshipEnd",
"_id": "AAAAAAFzmTidSGPmix0=",
"_parent": {
"$ref": "AAAAAAFzmTidSGPkITg="
},
"reference": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"cardinality": "0..*"
}
}
],
"columns": [
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmS+hAGMyFxQ=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMmKco="
},
"name": "id",
"type": "INTEGER",
"length": 0,
"primaryKey": true
},
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTArgGM8P34=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMmKco="
},
"name": "name",
"type": "varchar",
"length": "256"
},
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTKxMGNLYfU=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMmKco="
},
"name": "description",
"type": "varchar",
"length": "512"
},
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTMsN2NSMr0=",
"_parent": {
"$ref": "AAAAAAFzmS+aamMmKco="
},
"name": "date",
"type": "datetime",
"length": 0
}
]
},
{
"_type": "ERDEntity",
"_id": "AAAAAAFzmTUSMGOvbdY=",
"_parent": {
"$ref": "AAAAAAFyJv8bdImdWmM="
},
"name": "user_events",
"ownedElements": [
{
"_type": "ERDRelationship",
"_id": "AAAAAAFzmTsziWRExxQ=",
"_parent": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"end1": {
"_type": "ERDRelationshipEnd",
"_id": "AAAAAAFzmTsziWRFRrA=",
"_parent": {
"$ref": "AAAAAAFzmTsziWRExxQ="
},
"reference": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
}
},
"end2": {
"_type": "ERDRelationshipEnd",
"_id": "AAAAAAFzmTsziWRGUkg=",
"_parent": {
"$ref": "AAAAAAFzmTsziWRExxQ="
},
"reference": {
"$ref": "AAAAAAFzmTszCGQ4N4k="
},
"cardinality": "0..*"
}
},
{
"_type": "ERDRelationship",
"_id": "AAAAAAFzmTtiuWRye2I=",
"_parent": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"end1": {
"_type": "ERDRelationshipEnd",
"_id": "AAAAAAFzmTtiuWRzhic=",
"_parent": {
"$ref": "AAAAAAFzmTtiuWRye2I="
},
"reference": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
}
},
"end2": {
"_type": "ERDRelationshipEnd",
"_id": "AAAAAAFzmTtiuWR0NaQ=",
"_parent": {
"$ref": "AAAAAAFzmTtiuWRye2I="
},
"reference": {
"$ref": "AAAAAAFzmTrE/mQZtbU="
},
"cardinality": "0..*"
}
}
],
"columns": [
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTUsD2O8Tv0=",
"_parent": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"name": "id",
"type": "INTEGER",
"length": 0,
"primaryKey": true
},
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTVGIWPD9D4=",
"_parent": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"name": "user_id",
"type": "INTEGER",
"length": 0,
"foreignKey": true
},
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTVYxmPKgHI=",
"_parent": {
"$ref": "AAAAAAFzmTUSMGOvbdY="
},
"name": "event_id",
"type": "INTEGER",
"length": 0,
"foreignKey": true
}
]
},
{
"_type": "ERDEntity",
"_id": "AAAAAAFzmTicyGPYVxQ=",
"_parent": {
"$ref": "AAAAAAFyJv8bdImdWmM="
},
"name": "Entity2"
},
{
"_type": "ERDEntity",
"_id": "AAAAAAFzmTrE/mQZtbU=",
"_parent": {
"$ref": "AAAAAAFyJv8bdImdWmM="
},
"name": "users (find in user system)",
"columns": [
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTrWh2QmNU4=",
"_parent": {
"$ref": "AAAAAAFzmTrE/mQZtbU="
},
"name": "id",
"type": "INTEGER",
"length": 0,
"primaryKey": true
},
{
"_type": "ERDColumn",
"_id": "AAAAAAFzmTr2eGQvxRY=",
"_parent": {
"$ref": "AAAAAAFzmTrE/mQZtbU="
},
"name": "...",
"type": "...",
"length": 0
}
]
},
{
"_type": "ERDEntity",
"_id": "AAAAAAFzmTszCGQ4N4k=",
"_parent": {
"$ref": "AAAAAAFyJv8bdImdWmM="
},
"name": "Entity3"
},
{
"_type": "ERDEntity",
"_id": "AAAAAAFzmTtiNmRmWq4=",
"_parent": {
"$ref": "AAAAAAFyJv8bdImdWmM="
},
"name": "Entity4"
} }
] ]
} }

View File

@ -1,12 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class CalendarController extends Controller
{
// public function index()
}

View File

@ -1,95 +0,0 @@
<?php
//
//namespace App\Http\Controllers;
//
//use App\CalendarDate;
//use Illuminate\Http\Request;
//
//class CalendarDateController extends Controller
//{
// /**
// * Display a listing of the resource.
// *
// * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
// */
// public function index(Request $request)
// {
// $calendarDates = CalendarDate::query()->paginate($request->input("limit", 20));
//
// return view("calendar-date.index", [
// "calendarDates" => $calendarDates
// ]);
// }
//
// /**
// * Show the form for creating a new resource.
// *
// * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
// */
// public function create()
// {
// return view("calendar-date.create");
// }
//
// /**
// * Store a newly created resource in storage.
// *
// * @param \Illuminate\Http\Request $request
// * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
// */
// public function store(Request $request)
// {
// $fields = $request->validate([
// "" => ""
// ]);
//
// $calendarDate = new CalendarDate()
//
// return view("calendar-date.store");
// }
//
// /**
// * Display the specified resource.
// *
// * @param int $id
// * @return \Illuminate\Http\Response
// */
// public function show($id)
// {
// //
// }
//
// /**
// * Show the form for editing the specified resource.
// *
// * @param int $id
// * @return \Illuminate\Http\Response
// */
// public function edit($id)
// {
// //
// }
//
// /**
// * Update the specified resource in storage.
// *
// * @param \Illuminate\Http\Request $request
// * @param int $id
// * @return \Illuminate\Http\Response
// */
// public function update(Request $request, $id)
// {
// //
// }
//
// /**
// * Remove the specified resource from storage.
// *
// * @param int $id
// * @return \Illuminate\Http\Response
// */
// public function destroy($id)
// {
// //
// }
//}

View File

@ -11,6 +11,8 @@ class ExternalLinkController extends Controller
{ {
function __construct() function __construct()
{ {
$this->middleware([ "auth" ]);
$this->middleware("permission:link.external.list")->only("index"); $this->middleware("permission:link.external.list")->only("index");
$this->middleware("permission:link.external.create")->only(["create", "store"]); $this->middleware("permission:link.external.create")->only(["create", "store"]);
$this->middleware("permission:link.external.show")->only("show"); $this->middleware("permission:link.external.show")->only("show");

View File

@ -9,6 +9,17 @@ use Spatie\Permission\Models\Role;
class rolesController extends Controller class rolesController extends Controller
{ {
public function __construct()
{
$this->middleware([ "auth" ]);
$this->middleware([ "check.auth:roles.list" ])->only("index");
$this->middleware([ "check.auth:roles.show" ])->only("show");
$this->middleware([ "check.auth:roles.create" ])->only("create", "store");
$this->middleware([ "check.auth:roles.edit" ])->only("edit", "update");
$this->middleware([ "check.auth:roles.delete" ])->only("delete");
}
/** /**
* Display a listing of the resource. * Display a listing of the resource.
* *

View File

@ -13,6 +13,9 @@ class RootController extends Controller
} }
public function index() { public function index() {
if(auth()->user()->can('admin.panel.show'))
return Response::detect("root.index"); return Response::detect("root.index");
else
return view('app.root.index');
} }
} }

View File

@ -61,29 +61,21 @@ class UserController extends Controller
*/ */
public function store(Request $request) public function store(Request $request)
{ {
// Log::debug("STORE FUNCTION");
$data = $request->validate([ $data = $request->validate([
"name_first" => "required|max:255", "name_first" => "required|max:255",
"name_last" => "required|max:255", "name_last" => "required|max:255",
"email" => "required|email|unique:users", "email" => "required|email|unique:users",
"password" => "required|max:60", "password" => "required|max:60",
"phone" => "required|unique:users", "phone" => "required|unique:users",
]); ]);
// Log::debug("FINISHED VALIDATION?");
$rolez = $request->input("roles", [ "User" ]); $rolez = $request->input("roles", [ "User" ]);
$user = new User($data); $user = new User($data);
// Log::debug("CREATED USER [NOT PERSISTED YET]");
$user->assignRole($rolez); $user->assignRole($rolez);
$user->save(); $user->save();
// Log::debug("SAVED USER");
return Response::detect("users.store"); return Response::detect("users.store");
} }
@ -228,6 +220,7 @@ class UserController extends Controller
if(Auth::attempt($data)) { if(Auth::attempt($data)) {
//TODO: Implement home? //TODO: Implement home?
return redirect()->route("root.index"); return redirect()->route("root.index");
} }

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\WashingMachine; use App\WashingMachine;
use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Foundation\Auth\User;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
@ -46,7 +47,8 @@ class WashingReservationController extends Controller
public function create() public function create()
{ {
$machines = WashingMachine::all(); $machines = WashingMachine::all();
return Response::detect("washing-reservations.create", [ 'machines' => $machines ]); $users = User::all();
return Response::detect("washing-reservations.create", [ 'machines' => $machines, 'users' => $users ]);
} }
/** /**
@ -59,7 +61,8 @@ class WashingReservationController extends Controller
{ {
$data = $request->validate([ $data = $request->validate([
"time" => "required", "time" => "required",
"machine" => "required" "machine_id" => "required|unique:washing_reservations,machine_id,NULL,id,time,' . $request->time",
"user_id" => "required"
]); ]);
$machineReservation = new WashingReservation($data); $machineReservation = new WashingReservation($data);
@ -67,14 +70,14 @@ class WashingReservationController extends Controller
$saved = $machineReservation->save(); $saved = $machineReservation->save();
if(!$saved){ if (!$saved) {
return Response::detect("washing-reservations.store", [ return Response::detect("washing-reservations.store", [
"washing_reservation" => $machineReservation "washing_reservation" => $machineReservation
]); ]);
}else{ } else {
$reservations = WashingReservation::query()->paginate($request->input("limit", 20)); $reservations = WashingReservation::query()->paginate($request->input("limit", 20));
return Response::detect("washing-reservations.index", [ "reservations" => $reservations]); return Response::detect("washing-reservations.index", ["reservations" => $reservations]);
} }
} }
@ -160,7 +163,15 @@ class WashingReservationController extends Controller
$machines = WashingMachine::all(); $machines = WashingMachine::all();
$output = json_encode(['date' => $date, 'washingmachines' => $machines]); $reservations = WashingReservation::query()->where("time", "LIKE", substr($date, 1, strpos($date, "T"))."%")->get();
$times = [];
foreach ($reservations as $reservation){
array_push($times, $reservation->time);
}
//2020-07-28%
$output = json_encode(['date' => $date, 'washingmachines' => $machines, 'unavailable_times' => $times]);
return Response($output); return Response($output);
} }
} }

View File

@ -14,6 +14,6 @@ class WashingReservation extends Model
{ {
//protected variable which contains name of database field(s) to be filled. //protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
'time', 'machine' 'time', 'machine_id', 'user_id'
]; ];
} }

View File

@ -19,8 +19,11 @@ class CreateWashingReservations extends Migration
$table->id(); $table->id();
$table->timestamp("time"); $table->timestamp("time");
$table->timestamps(); $table->timestamps();
$table->unsignedBigInteger('machine'); $table->unsignedBigInteger('machine_id');
$table->foreign("machine")->references('id')->on('washing_machines'); $table->foreign("machine_id")->references('id')->on('washing_machines');
$table->unsignedBigInteger('user_id');
$table->foreign("user_id")->references('id')->on('users');
$table->unique(['time', 'machine_id']);
}); });
} }

View File

@ -13,5 +13,6 @@ class DatabaseSeeder extends Seeder
{ {
$this->call(PermissionSeeder::class); $this->call(PermissionSeeder::class);
$this->call(UserSeeder::class); $this->call(UserSeeder::class);
$this->call(RoleSeeder::class);
} }
} }

View File

@ -98,6 +98,14 @@ class PermissionSeeder extends Seeder
"washing.machine.reservation.edit" => "Allows editing of washing machine reservations", "washing.machine.reservation.edit" => "Allows editing of washing machine reservations",
"washing.machine.reservation.delete" => "Allows deletion of washing machine reservations", "washing.machine.reservation.delete" => "Allows deletion of washing machine reservations",
"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",
]; ];

View File

@ -12,10 +12,8 @@ class RoleSeeder extends Seeder
public function run() public function run()
{ {
$roles = [ $roles = [
"administrator" => "Admin", "Administrator" => "Administrator",
"user" => "Userstuff", "User" => "Bruger",
]; ];
foreach ($roles as $key => $value) { foreach ($roles as $key => $value) {

View File

@ -15,13 +15,20 @@
@csrf @csrf
<label for="time">Tidspunkt:</label> <label for="time">Tidspunkt:</label>
<input type="datetime-local" name="time" id="time" required> <input type="datetime-local" name="time" id="time" required>
<label for="machine">Vaskemaskine:</label> <label for="machine_id">Vaskemaskine:</label>
<select name="machine" id="machine" required> <select name="machine_id" id="machine_id" required>
<option disabled selected value> -- Vælg Vaskemaskine -- </option> <option disabled selected value> -- Vælg Vaskemaskine -- </option>
@foreach($machines as $machine) @foreach($machines as $machine)
<option value="{{ $machine->id }}">{{ $machine->name }}</option> <option value="{{ $machine->id }}">{{ $machine->name }}</option>
@endforeach @endforeach
</select> </select>
<label for="user_id">Bruger:</label>
<select name="user_id" id="user_id" required>
<option disabled selected value> -- Vælg Bruger -- </option>
@foreach($users as $user)
<option value="{{ $user->id }}">{{ ucfirst($user->name_first) }} {{ ucfirst($user->name_last) }}</option>
@endforeach
</select>
<input type="submit" class="btn btn-dark text-white" value="Opret"> <input type="submit" class="btn btn-dark text-white" value="Opret">
</form> </form>
@endsection @endsection

View File

@ -28,7 +28,7 @@
</tr> </tr>
@foreach($reservations as $reservation) @foreach($reservations as $reservation)
<tr> <tr>
<td>{{ \App\WashingMachine::query()->find($reservation->machine)->name }}</td> <td>{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}</td>
<td>{{ $reservation->time }}</td> <td>{{ $reservation->time }}</td>
<td><a href="{{ route('washing-reservations.edit', ['washing_reservation' => $reservation]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td> <td><a href="{{ route('washing-reservations.edit', ['washing_reservation' => $reservation]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td><form method="post" action="{{ route('washing-reservations.destroy', ['washing_reservation' => $reservation]) }}" class="w-100 nostyle"> <td><form method="post" action="{{ route('washing-reservations.destroy', ['washing_reservation' => $reservation]) }}" class="w-100 nostyle">

View File

@ -1,5 +1,4 @@
@extends("app.layout.base") @extends("app.layout.base")
@extends("app.layout.header")
@section("title") @section("title")
Kontakt Kontakt
@endsection @endsection

View File

@ -1,5 +1,4 @@
@extends("app.layout.base") @extends("app.layout.base")
@extends("app.layout.header")
@section("title") @section("title")
Aktiviteter Aktiviteter
@endsection @endsection

View File

@ -1,5 +1,4 @@
@extends("app.layout.base") @extends("app.layout.base")
@extends("app.layout.header")
@section("title") @section("title")
Menuplan Menuplan
@endsection @endsection

View File

@ -1,5 +1,4 @@
@extends("app.layout.base") @extends("app.layout.base")
@extends("app.layout.header")
@section("title") @section("title")
Vagttelefon Vagttelefon
@endsection @endsection

View File

@ -1,5 +1,5 @@
@extends("app.layout.base") @extends("app.layout.base")
@extends("app.layout.header")
@section("title") @section("title")
Booking Liste Booking Liste
@endsection @endsection
@ -27,6 +27,7 @@
</div> </div>
<form method="post" action="{{ route("washing-reservations.store") }}" id="event-container" class="events-container"> <form method="post" action="{{ route("washing-reservations.store") }}" id="event-container" class="events-container">
@csrf @csrf
<input type="hidden" value="{{auth()->user()->id}}" name="user_id">
<p> <p>
Maskiner skal dynamisk opdateres alt efter om det er en fra bygning E eller en af de andre bygninger der vil vaske, da bygning E har egen vaskekælder! Maskiner skal dynamisk opdateres alt efter om det er en fra bygning E eller en af de andre bygninger der vil vaske, da bygning E har egen vaskekælder!
</p> </p>
@ -112,7 +113,7 @@
axios({ axios({
method: 'get', method: 'get',
url: '/washing-reservationsapi', url: '{{ route("washing-reservations.api") }}',
params: { 'date': date } params: { 'date': date }
}).then(function (response) { }).then(function (response) {
var data = response.data; var data = response.data;
@ -127,7 +128,7 @@
let select = document.createElement("select"); let select = document.createElement("select");
select.classList.add("events__title"); select.classList.add("events__title");
select.id = "washing-machines"; select.id = "washing-machines";
select.name = "machine"; select.name = "machine_id";
container.appendChild(span); container.appendChild(span);
container.appendChild(select); container.appendChild(select);
@ -139,7 +140,7 @@
else { else {
let span = document.createElement("span"); let span = document.createElement("span");
span.classList.add("events__title"); span.classList.add("events__title");
span.innerText = "Tider"; span.innerText = "Tilgængelige tider";
let select = document.createElement("select"); let select = document.createElement("select");
select.classList.add("events__title"); select.classList.add("events__title");
@ -178,13 +179,33 @@
events.innerHTML = ""; events.innerHTML = "";
for (let hour = 8; hour <= 20; hour++) { for (let hour = 8; hour <= 20; hour++) {
let value = data["date"].split("T")[0].slice(1, data["date"].split("T")[0].length) + "T" + prependZero(hour) + ":00";
let option = document.createElement("option"); let option = document.createElement("option");
option.text = prependZero(hour) + ":00";
option.value = data["date"].split("T")[0].slice(1, data["date"].split("T")[0].length) + "T" + prependZero(hour) + ":00";
option.text = prependZero(hour) + ":00";
option.value = value;
option.id = value;
events.appendChild(option); events.appendChild(option);
} }
let unavailable_times = data["unavailable_times"];
unavailable_times.forEach(function (item, index) {
console.log(item);
document.getElementById(item).remove();
});
if(events.childElementCount == 0){
let option = document.createElement("option");
option.disabled = "disabled";
option.text = "Der er ingen tilgængelige tider";
option.selected = "selected";
events.appendChild(option);
document.getElementById("create-reservation").disabled = "disabled";
} else {
document.getElementById("create-reservation").disabled = "";
}
}); });
} }

View File

@ -1,5 +1,4 @@
@extends("app.layout.base") @extends("app.layout.base")
@extends("app.layout.header")
@section("title") @section("title")
Booking Liste Booking Liste
@endsection @endsection