Merge branch 'master' into LiveSearch

This commit is contained in:
Neerholt 2020-07-27 14:23:13 +02:00 committed by GitHub
commit 519bd70ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 439 additions and 134 deletions

View File

@ -1,11 +1,18 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none needed. the class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class Album extends Model class Album extends Model
{ {
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
'name' 'name'
]; ];

View File

@ -1,9 +1,15 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class CalendarDate extends Model class CalendarDate extends Model
{ {
// //

View File

@ -1,9 +1,16 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class CalendarEvent extends Model class CalendarEvent extends Model
{ {
// //

View File

@ -1,12 +1,20 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class Contact extends Model class Contact extends Model
{ {
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
'name_first', "name_last", 'email', 'phone' 'contactname', "title", 'email', 'phone'
]; ];
} }

View File

@ -1,9 +1,16 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class Event extends Model class Event extends Model
{ {
/** /**
@ -11,6 +18,7 @@ class Event extends Model
* *
* @var array * @var array
*/ */
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
"name", "description", "date" "name", "description", "date"
]; ];

View File

@ -1,9 +1,16 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class ExternalLink extends Model class ExternalLink extends Model
{ {
/** /**
@ -11,6 +18,7 @@ class ExternalLink extends Model
* *
* @var array * @var array
*/ */
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
'name', "link" 'name', "link"
]; ];

View File

@ -1,9 +1,16 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class Feedbacks extends Model class Feedbacks extends Model
{ {
protected $fillable = [ protected $fillable = [

View File

@ -7,7 +7,7 @@ use Illuminate\Http\Response;
use App\Contact; use App\Contact;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Context;
//hello
class ContactController extends Controller class ContactController extends Controller
{ {
public function __construct() public function __construct()
@ -54,8 +54,8 @@ class ContactController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$requestContact = $request->validate([ $requestContact = $request->validate([
"name_first" => "required|max:255", "contactname" => "required|max:255",
"name_last" => "required|max:255", "title" => "required|max:255",
"email" => "required|max:255", "email" => "required|max:255",
"phone" => "required|max:255", "phone" => "required|max:255",
]); ]);

View File

@ -29,8 +29,11 @@ class EventController extends Controller
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$events = Event::query()->paginate($request->input("limit", 20)); $events = Event::query()->paginate($request->input("limit", 20));
//returns the function with events index page and a parameter of events.
//also Response::detect checks screen size to determine if user is on a computer or mobile.
return Response::detect("events.index", [ "events" => $events]); return Response::detect("events.index", [ "events" => $events]);
} }
@ -41,6 +44,7 @@ class EventController extends Controller
*/ */
public function create() public function create()
{ {
//returns "create event" blade
return Response::detect("events.create"); return Response::detect("events.create");
} }
@ -58,6 +62,7 @@ class EventController extends Controller
"date" => "required" "date" => "required"
]); ]);
//creates a new Event model with the given parameter
$event = new Event($requestBody); $event = new Event($requestBody);
$saved = $event->save(); $saved = $event->save();

View File

@ -2,6 +2,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Resource;
use App\ResourceExtension;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
@ -23,9 +25,11 @@ class ResourceController extends Controller
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function index() public function index(Request $request)
{ {
$resources = Resource::query()->paginate($request->input("limit", 20));
return Response::detect("resources.index", [ "resources" => $resources ]);
} }
/** /**
@ -35,7 +39,7 @@ class ResourceController extends Controller
*/ */
public function create() public function create()
{ {
// return Response::detect("resources.create");
} }
/** /**
@ -46,7 +50,33 @@ class ResourceController extends Controller
*/ */
public function store(Request $request) public function store(Request $request)
{ {
// // $data = $request->validate([
// "" => ""
// ]);
// $resource = new Resource($data);
$file = $request->file("resource");
$resourceExtension = ResourceExtension::where("extension", "=", $file->extension())->first();
if($resourceExtension === null) {
//TODO: Create new resourceExtension!
}
else {
$resource = new Resource();
$resource->resourceExtension()->save($resourceExtension);
$resource->save();
}
return Response::detect("resources.store");
} }
/** /**

View File

@ -8,6 +8,7 @@ use Illuminate\Http\Response;
use App\User; use App\User;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Spatie\Permission\Models\Role; use Spatie\Permission\Models\Role;
@ -77,6 +78,7 @@ class UserController extends Controller
// Log::debug("CREATED USER [NOT PERSISTED YET]"); // Log::debug("CREATED USER [NOT PERSISTED YET]");
$user->assignRole([ "R1", "R2" ]);
$user->save(); $user->save();
// Log::debug("SAVED USER"); // Log::debug("SAVED USER");
@ -151,19 +153,36 @@ class UserController extends Controller
// else if(Auth::user()->hasPermissionTo("user.edit")) { // else if(Auth::user()->hasPermissionTo("user.edit")) {
$user = User::find($id); $user = User::find($id);
/** @var User $user */ if ($request->roles != null) { //You can only edit roles on the admin site, so if there is an input roles, then update user info and edit roles
$user->update($data); /** @var User $user */
$user->update($data);
if ($request->roles != null) {
$user->roles()->detach(); $user->roles()->detach();
$user->forgetCachedPermissions(); $user->forgetCachedPermissions();
foreach ($request->roles as $role){ foreach ($request->roles as $role){
$user->assignRole($role); $user->assignRole($role);
} }
//$user->save();
} else { // Else if you're not on the admin site (user site)
if ($request->input('password') != null) { // If you're editing the password
if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back.
return Response::detect("users.editpass");
} elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back.
return Response::detect("users.editpass");
} else { // If new password and current password is the same AND current written and current DB password is the same. Then update and logout.
/** @var User $user */
$user->update($data);
Auth::logout();
return redirect()->route("users.login");
}
} else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
$user->update($data);
}
} }
$user->save();
// } // }
$users = User::query()->paginate(20); $users = User::query()->paginate(20);

View File

@ -2,10 +2,13 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use App\WashingMachine; use App\WashingMachine;
use Illuminate\View\View;
class WashingMachineController extends Controller class WashingMachineController extends Controller
{ {
@ -24,11 +27,11 @@ class WashingMachineController extends Controller
* Display a listing of the resource. * Display a listing of the resource.
* *
* @param Request $request * @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$machines = WashingMachine::query()->paginate($request->query("page", 1)); $machines = WashingMachine::query()->paginate($request->query("limit", 20));
return Response::detect("washing-machines.index", [ "machines" => $machines ]); return Response::detect("washing-machines.index", [ "machines" => $machines ]);
} }
@ -36,7 +39,7 @@ class WashingMachineController extends Controller
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* *
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function create() public function create()
{ {
@ -47,25 +50,30 @@ class WashingMachineController extends Controller
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$data = $request->validate([ $data = $request->validate([
"time" => "required" "name" => "required"
]); ]);
$machine = new WashingMachine($data); $machine = new WashingMachine($data);
$machine->save(); $saved = $machine->save();
return Response::detect("washing-machines.store"); if(!$saved){
return Response::detect("washing-machines.store");
}else{
$machines = WashingMachine::query()->paginate($request->input("limit", 20));
return Response::detect("washing-machines.index", ['machines' => $machines]);
}
} }
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function show($id) public function show($id)
{ {
@ -80,7 +88,7 @@ class WashingMachineController extends Controller
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function edit($id) public function edit($id)
{ {
@ -96,36 +104,43 @@ class WashingMachineController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
$data = $request->validate([ $data = $request->validate([
"time" => "required" "name" => "required"
]); ]);
$machine = WashingMachine::find($id); $machine = WashingMachine::find($id);
$machine->update($data); $machine->update($data);
$machine->save(); $saved = $machine->save();
return Response::detect("washing-machines.edit", [ if(!$saved){
"machine" => $machine return Response::detect("washing-machines.update", [
]); "machine" => $machine
]);
} else {
$machines = WashingMachine::query()->paginate($request->input("limit", 20));
return Response::detect("washing-machines.index", [
"machines" => $machines
]);
}
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Response
*/ */
public function destroy($id) public function destroy($id)
{ {
$machine = WashingMachine::find($id); $machine = WashingMachine::find($id);
$machine->delete(); $machine->delete();
return Response::detect("washing-machines.destroy"); return redirect()->route("washing-machines.index");
} }
} }

View File

@ -2,10 +2,15 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\WashingMachine;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use App\WashingReservation; use App\WashingReservation;
use Illuminate\View\View;
class WashingReservationController extends Controller class WashingReservationController extends Controller
{ {
@ -24,11 +29,11 @@ class WashingReservationController extends Controller
* Display a listing of the resource. * Display a listing of the resource.
* *
* @param Request $request * @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function index(Request $request) public function index(Request $request)
{ {
$reservations = WashingReservation::query()->paginate($request->query("page", 1)); $reservations = WashingReservation::query()->paginate($request->query("limit", 20));
return Response::detect("washing-reservations.index", [ "reservations" => $reservations]); return Response::detect("washing-reservations.index", [ "reservations" => $reservations]);
} }
@ -36,36 +41,48 @@ class WashingReservationController extends Controller
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* *
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function create() public function create()
{ {
return Response::detect("washing-reservations.create"); $machines = WashingMachine::all();
return Response::detect("washing-reservations.create", [ 'machines' => $machines ]);
} }
/** /**
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$data = $request->validate([ $data = $request->validate([
"time" => "required" "time" => "required",
"machine" => "required"
]); ]);
$machineReservation = new WashingReservation($data); $machineReservation = new WashingReservation($data);
$machineReservation->save(); $machineReservation->save();
return Response::detect("washing-reservations.store"); $saved = $machineReservation->save();
if(!$saved){
return Response::detect("washing-reservations.store", [
"washing_reservation" => $machineReservation
]);
}else{
$reservations = WashingReservation::query()->paginate($request->input("limit", 20));
return Response::detect("washing-reservations.index", [ "reservations" => $reservations]);
}
} }
/** /**
* Display the specified resource. * Display the specified resource.
* *
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function show($id) public function show($id)
{ {
@ -80,11 +97,14 @@ class WashingReservationController extends Controller
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function edit($id) public function edit($id)
{ {
return Response::detect("washing-reservations.edit"); $reservation = WashingReservation::query()->find($id);
$machines = WashingMachine::all();
return Response::detect("washing-reservations.edit", ['washing_reservation' => $reservation, 'machines' => $machines ]);
} }
/** /**
@ -92,36 +112,45 @@ class WashingReservationController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return Application|Factory|View
*/ */
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
$data = $request->validate([ $data = $request->validate([
"time" => "required" "time" => "required",
"machine" => "required"
]); ]);
$machineReservation = WashingReservation::find($id); $machineReservation = WashingReservation::find($id);
$machineReservation->update($data); $machineReservation->update($data);
$machineReservation->save(); $saved = $machineReservation->save();
return Response::detect("washing-reservations.edit", [ if(!$saved){
"washingReservation" => $machineReservation 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]);
}
} }
/** /**
* Remove the specified resource from storage. * Remove the specified resource from storage.
* *
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return RedirectResponse
*/ */
public function destroy($id) public function destroy($id)
{ {
$machineReservation = WashingReservation::find($id); $machineReservation = WashingReservation::find($id);
$machineReservation->delete(); $machineReservation->delete();
return Response::detect("washing-reservations.delete"); $reservations = WashingReservation::query()->paginate( 20);
return redirect()->route("washing-reservations.index", [ "reservations" => $reservations]);
} }
} }

View File

@ -10,9 +10,11 @@ class CheckAuth
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @param $permissions
* @return mixed * @return mixed
* @throws \Exception
*/ */
public function handle($request, Closure $next, $permissions) public function handle($request, Closure $next, $permissions)
{ {

View File

@ -1,11 +1,19 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class MenuPlan extends Model class MenuPlan extends Model
{ {
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
'week', 'monday', "tuesday", 'wednesday', 'thursday' 'week', 'monday', "tuesday", 'wednesday', 'thursday'
]; ];

View File

@ -1,10 +1,22 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class Resource extends Model class Resource extends Model
{ {
// public function resourceExtension() {
return $this->belongsTo("App\ResourceExtension");
}
public function resourceCategory() {
return $this->hasOneThrough("App\ResourceCategory", "App\ResourceExtension");
}
} }

View File

@ -1,10 +1,18 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class ResourceCategory extends Model class ResourceCategory extends Model
{ {
// public function resourceExtensions() {
return $this->hasMany("App\ResourceExtension");
}
} }

View File

@ -1,10 +1,18 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class ResourceExtension extends Model class ResourceExtension extends Model
{ {
// public function resources() {
return $this->hasMany("App\Resource");
}
} }

View File

@ -1,7 +1,12 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of many libraries.
use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
@ -10,6 +15,7 @@ use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Spatie\Permission\Traits\HasRoles; use Spatie\Permission\Traits\HasRoles;
//Class of which should extend Model Library
class User extends Authenticatable class User extends Authenticatable
{ {
use Notifiable; use Notifiable;
@ -20,6 +26,7 @@ class User extends Authenticatable
* *
* @var array * @var array
*/ */
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [ protected $fillable = [
'name_first', "name_last", 'email', 'password', "phone" 'name_first', "name_last", 'email', 'password', "phone"
]; ];

View File

@ -1,10 +1,19 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class WashingMachine extends Model class WashingMachine extends Model
{ {
// //protected variable which contains name of database field(s) to be filled.
protected $fillable = [
'name'
];
} }

View File

@ -1,10 +1,19 @@
<?php <?php
//The Model to a certain Controller, should contain a class with Controller name to which it belongs.
// Allows needed strings to passed onto the database. if there is none. class should appear empty.
//Reference to where the file belongs.
namespace App; namespace App;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class WashingReservation extends Model class WashingReservation extends Model
{ {
// //protected variable which contains name of database field(s) to be filled.
protected $fillable = [
'time', 'machine'
];
} }

View File

@ -17,6 +17,8 @@ class CreateWashingReservations extends Migration
$table->id(); $table->id();
$table->timestamp("time"); $table->timestamp("time");
$table->timestamps(); $table->timestamps();
$table->unsignedBigInteger('machine');
$table->foreign("machine")->references('id')->on('washing_machines');
}); });
} }

View File

@ -16,8 +16,8 @@ class CreateContact extends Migration
Schema::create('contacts', function (Blueprint $table) { Schema::create('contacts', function (Blueprint $table) {
$table->id(); $table->id();
$table->timestamps(); $table->timestamps();
$table->string('name_first', 255); $table->string('contactname', 255);
$table->string('name_last', 255); $table->string('title', 255);
$table->string('email', 255); $table->string('email', 255);
$table->integer('phone'); $table->integer('phone');
//$table->unique('email'); //$table->unique('email');

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateResourceCategory extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('resource_categories', function (Blueprint $table) {
$table->id();
$table->string("name", 60)->unique();
$table->text("description");
$table->string("slug", 255)->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('resource_categories');
}
}

View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
class CreateResourceExtensions extends Migration class CreateResourceExtension extends Migration
{ {
/** /**
* Run the migrations. * Run the migrations.
@ -15,9 +15,12 @@ class CreateResourceExtensions extends Migration
{ {
Schema::create('resource_extensions', function (Blueprint $table) { Schema::create('resource_extensions', function (Blueprint $table) {
$table->id(); $table->id();
$table->string("extension")->unique(); $table->string("extension", 60)->unique();
$table->text("description"); $table->text("description");
$table->unsignedInteger("resource_category_id");
$table->timestamps(); $table->timestamps();
$table->foreign("resource_category_id")->references("id")->on("resource_categories");
}); });
} }

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateResource extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('resources', function (Blueprint $table) {
$table->id();
$table->string("filename")->unique();
$table->unsignedInteger("extension_id");
$table->timestamps();
$table->foreign("extension_id")->references("id")->on("resource_extensions");
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('resources');
}
}

View File

@ -17,6 +17,7 @@ class PermissionSeeder extends Seeder
/** /**
* The USER specific permissions * The USER specific permissions
*/ */
"user.create" => "Creation of new user",
"user.list" => "Access to list the users.", "user.list" => "Access to list the users.",
"user.show" => "Shows another user profile.", "user.show" => "Shows another user profile.",
"user.edit" => "Allows editing of other users.", "user.edit" => "Allows editing of other users.",

View File

@ -19,13 +19,13 @@ class UserSeeder extends Seeder
// } catch (Exception $e) { // } catch (Exception $e) {
// } // }
Log::debug("YEET");
if(User::where("name_first", "admin"))
/*if(User::where("name_first", "admin"))
{ {
return; return;
} }*/

View File

@ -13,10 +13,10 @@
<h1>Opret Kontakt:</h1> <h1>Opret Kontakt:</h1>
<form method="post" action="{{ route("contacts.store") }}"> <form method="post" action="{{ route("contacts.store") }}">
@csrf @csrf
<label for="name_first">Fornavn:</label> <label for="contactname">Kontakt Navn:</label>
<input type="text" name="name_first" id="name_first" placeholder="Fornavn" required> <input type="text" name="contactname" id="contactname" placeholder="Navn" required>
<label for="name_last">Efternavn:</label> <label for="title">Titel:</label>
<input type="text" name="name_last" id="name_last" placeholder="Efternavn" required> <input type="text" name="title" id="title" placeholder="Titel" required>
<label for="email">Email:</label> <label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="x@y.z" required> <input type="email" name="email" id="email" placeholder="x@y.z" required>
<label for="tel">Telefon nr:</label> <label for="tel">Telefon nr:</label>

View File

@ -14,10 +14,10 @@
<form method="post" action="{{ route("contacts.update", ['contact' => $contact]) }}"> <form method="post" action="{{ route("contacts.update", ['contact' => $contact]) }}">
@csrf @csrf
@method("put") @method("put")
<label for="name_first">Fornavn:</label> <label for="contactname">Kontakt Navn:</label>
<input type="text" name="name_first" id="name_first" placeholder="Fornavn" value="{{ $contact->name_first }}" required> <input type="text" name="contactname" id="contactname" placeholder="Navn" value="{{ $contact->contactname }}" required>
<label for="name_last">Efternavn:</label> <label for="title">Titel:</label>
<input type="text" name="name_last" id="name_last" placeholder="Efternavn" value="{{ $contact->name_last }}" required> <input type="text" name="title" id="title" placeholder="Titel" value="{{ $contact->title }}" required>
<label for="email">Email:</label> <label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="x@y.z" value="{{ $contact->email }}" required> <input type="email" name="email" id="email" placeholder="x@y.z" value="{{ $contact->email }}" required>
<label for="tel">Telefon nr:</label> <label for="tel">Telefon nr:</label>

View File

@ -32,8 +32,8 @@
</tr> </tr>
@foreach($contacts as $contact) @foreach($contacts as $contact)
<tr> <tr>
<td>{{ $contact->name_first }}</td> <td>{{ $contact->contactname }}</td>
<td>{{ $contact->name_last }}</td> <td>{{ $contact->title }}</td>
<td>{{ $contact->email }}</td> <td>{{ $contact->email }}</td>
<td>{{ $contact->phone }}</td> <td>{{ $contact->phone }}</td>
<td><a href="{{ route("contacts.edit", [ "contact" => $contact ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td> <td><a href="{{ route("contacts.edit", [ "contact" => $contact ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>

View File

@ -19,20 +19,35 @@
<label for="name_last">Efternavn:</label> <label for="name_last">Efternavn:</label>
<input type="text" name="name_last" id="name_last" value="{{ $user->name_last }}" required> <input type="text" name="name_last" id="name_last" value="{{ $user->name_last }}" required>
<label for="email">Email:</label> <label for="email">Email:</label>
<input type="email" name="email" id="email" value="{{ $user->name_email }}" required> <input type="email" name="email" id="email" value="{{ $user->email }}" required>
<label for="password1">Password:</label> <label for="password1">Password: (Forblives blank, hvis password ikke skal ændres)</label>
<input type="password" name="password" id="password1" value="" required> <input type="password" name="password" id="password1" value="">
<label for="password2">Confirm Password:</label> <label for="password2">Confirm Password: (Forblives blank, hvis password ikke skal ændres)</label>
<input type="password" id="password2" value="" required> <input type="password" id="password2" value="">
<label for="tel">Telefon nr:</label> <label for="tel">Telefon nr:</label>
<input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required> <input type="tel" name="phone" id="tel" value="{{ $user->phone }}" required>
<label for="role">Rolle:</label> <label for="role">Rolle: (Brug ctrl og shift til at vælge flere)</label>
<select name="roles[]" id="roles" class="mb-2" multiple="multiple" required> <select name="roles[]" id="roles" class="mb-2" multiple="multiple" required>
<option disabled selected value> -- Vælg Rolle(r) -- </option> @if(count($user->roles) == 0)
<option value>Ingen Rolle</option> <option disabled selected> -- Vælg Rolle(r) -- </option>
@foreach($roles as $role) <option value>Ingen Rolle</option>
<option value="{{ $role->name }}">{{ $role->name }}</option> @foreach($roles as $role)
@endforeach <option value="{{ $role->name }}">{{ $role->name }}</option>
@endforeach
@else
<option disabled> -- Vælg Rolle(r) -- </option>
<option value>Ingen Rolle</option>
@foreach($roles as $role)
{{ $selected = "" }}
@foreach($user->roles as $userRole)
@if($userRole->id == $role->id)
{{ $selected = "selected" }}
@endif
@endforeach
<option {{ $selected }} value="{{ $role->name }}">{{ $role->name }}</option>
@endforeach
@endif
</select> </select>
<input type="submit" class="btn btn-dark text-white" value="Rediger"> <input type="submit" class="btn btn-dark text-white" value="Rediger">
</form> </form>

View File

@ -6,7 +6,7 @@
@endsection @endsection
@section("path") @section("path")
<a href="{{ route('washing-machines.delete') }}" class="text-white">Fjern Vaskemaskine</a> / <a href="{{ route('washing-machines.destroy') }}" class="text-white">Fjern Vaskemaskine</a> /
@endsection @endsection
@section("content") @section("content")

View File

@ -6,14 +6,15 @@
@endsection @endsection
@section("path") @section("path")
<a href="{{ route('washing-machines.edit', ['id' => $user->id]) }}" class="text-white">Rediger Vaskemaskiner</a> / <a href="{{ route('washing-machines.edit', ['washing_machine' => $machine]) }}" class="text-white">Rediger Vaskemaskiner</a> /
@endsection @endsection
@section("content") @section("content")
<form method="post" action="{{ route("washing-machines.store") }}"> <form method="post" action="{{ route("washing-machines.update", [ 'washing_machine' => $machine]) }}">
@csrf @csrf
@method("put")
<label for="name_first">Vaskemaskine Navn:</label> <label for="name_first">Vaskemaskine Navn:</label>
<input type="text" name="name" id="name" max="60" required> <input type="text" name="name" id="name" max="60" value="{{$machine->name}}" required>
<input type="submit" class="btn btn-dark text-white" value="Opret"> <input type="submit" class="btn btn-dark text-white" value="Rediger">
</form> </form>
@endsection @endsection

View File

@ -21,9 +21,9 @@
</tr> </tr>
@foreach($machines as $machine) @foreach($machines as $machine)
<tr> <tr>
<td>{Navn}</td> <td>{{$machine->name}}</td>
<td><a href=""><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td> <td><a href="{{ route('washing-machines.edit', [ 'washing_machine' => $machine ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td><form method="post" action="{{ route("washing-machines.destroy", [ "machine" => $machine ]) }}" class="w-100 nostyle"> <td><form method="post" action="{{ route('washing-machines.destroy', [ 'washing_machine' => $machine ]) }}" class="w-100 nostyle">
@csrf @csrf
@method("delete") @method("delete")
@ -33,6 +33,4 @@
</tr> </tr>
@endforeach @endforeach
</table> </table>
{{ $machines->links() }}
@endsection @endsection

View File

@ -6,21 +6,21 @@
@endsection @endsection
@section("path") @section("path")
<a href="{{ route('washing-reservations.create') }}" class="text-white">Opret Vaske Reservationer</a> / <a href="{{ route('washing-reservations.create') }}" class="text-white">Opret Vaskemaskine Reservation</a> /
@endsection @endsection
@section("content") @section("content")
<h1>Opret Booking:</h1> <h1>Opret Reservation:</h1>
<form method="post" action="{{ route("washing-reservations.store") }}"> <form method="post" action="{{ route("washing-reservations.store") }}">
@csrf @csrf
<label for="name_first">Fornavn:</label> <label for="time">Tidspunkt:</label>
<input type="text" name="name_first" id="name_first" required> <input type="datetime-local" name="time" id="time" required>
<label for="name_last">Efternavn:</label> <label for="machine">Vaskemaskine:</label>
<input type="text" name="name_last" id="name_last" required> <select name="machine" id="machine" required>
<label for="tel">Telefon nr:</label> <option disabled selected value> -- Vælg Vaskemaskine -- </option>
<input type="tel" name="phone" id="tel" required> @foreach($machines as $machine)
<select name="machine_choice"> <option value="{{ $machine->id }}">{{ $machine->name }}</option>
<option>Vaskemaskine 1</option> @endforeach
</select> </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>

View File

@ -6,22 +6,26 @@
@endsection @endsection
@section("path") @section("path")
<a href="{{ route('washing-reservations.edit', ['id' => $reservations->id]) }}" class="text-white">Rediger Vaske Reservationer</a> / <a href="{{ route('washing-reservations.edit', ['washing_reservation' => $washing_reservation]) }}" class="text-white">Rediger Vaske Reservationer</a> /
@endsection @endsection
@section("content") @section("content")
<h1>Rediger Booking:</h1> <h1>Rediger Booking:</h1>
<form method="post" action=""> <form method="post" action="{{ route('washing-reservations.update', ['washing_reservation' => $washing_reservation ]) }}">
@csrf @csrf
<label for="name_first">Fornavn:</label> @method("put")
<input type="text" name="name_first" id="name_first" value="{Fornavn}" required> <label for="time">Tidspunkt:</label>
<label for="name_last">Efternavn:</label> <input type="datetime-local" name="time" id="time" value="{{ $washing_reservation->time }}" required>
<input type="text" name="name_last" id="name_last" value="{Efternavn}" required> <label for="machine">Vaskemaskine:</label>
<input type="password" id="password2" value="{Password}" required> <select name="machine" id="machine" required>
<label for="tel">Telefon nr:</label> <option disabled value> -- Vælg Vaskemaskine -- </option>
<input type="tel" name="phone" id="tel" value="{Telefon}" required> @foreach($machines as $machine)
<select> @if($machine->id == $washing_reservation->machine)
<option>Vaskemaskine 1</option> <option selected value="{{ $machine->id }}">{{ $machine->name }}</option>
@else
<option value="{{ $machine->id }}">{{ $machine->name }}</option>
@endif
@endforeach
</select> </select>
<input type="submit" class="btn btn-dark text-white" value="Rediger"> <input type="submit" class="btn btn-dark text-white" value="Rediger">
</form> </form>

View File

@ -21,21 +21,17 @@
</div> </div>
<table class="tbl mt-2"> <table class="tbl mt-2">
<tr> <tr>
<th>Fornavn</th>
<th>Efternavn</th>
<th>Tlf nr</th>
<th>Vaskemaskine</th> <th>Vaskemaskine</th>
<th>Time</th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th> <th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
<th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th> <th style="width: 1em;"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
</tr> </tr>
@foreach($reservations as $reservation) @foreach($reservations as $reservation)
<tr> <tr>
<td>{Fornavn}</td> <td>{{ \App\WashingMachine::query()->find($reservation->machine)->name }}</td>
<td>{Efternavn}</td> <td>{{ $reservation->time }}</td>
<td>{Tlf Nr}</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>{Vaskemaskine Nr.}</td> <td><form method="post" action="{{ route('washing-reservations.destroy', ['washing_reservation' => $reservation]) }}" class="w-100 nostyle">
<td><a href=""><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td><form method="post" action="" class="w-100 nostyle">
@csrf @csrf
@method("delete") @method("delete")

View File

@ -2,13 +2,13 @@
@extends("admin.layout.header") @extends("admin.layout.header")
@section("title") @section("title")
Vaske Reservationer - Rediger Vaskemaskine Reservationer - Rediger
@endsection @endsection
@section("path") @section("path")
<a href="{{ route('washing-reservations.edit') }}" class="text-white">Rediger Vaske Reservationer</a> / <a href="{{ route('washing-reservations.edit', ['washing_reservation' => $washing_reservation]) }}" class="text-white">Rediger Vaskemaskine Reservationer</a> /
@endsection @endsection
@section("content") @section("content")
Din Vaske Reservationer blev (ikke) redigeret. Din Vaskemaskine Reservationer blev (ikke) redigeret.
@endsection @endsection

View File

@ -7,11 +7,15 @@
@section("content") @section("content")
<main> <main>
<h1 class="text-center sde-blue mb-0">Aktiviteter</h1> <h1 class="text-center sde-blue mb-0">Aktiviteter</h1>
@foreach($events as $event) @if(!$events->isEmpty())
<h3 class="sde-blue bold text-center mb-0">{{$event->name}}</h3> @foreach($events as $event)
<p class="text-center mt-0">{{$event->date}}</p> <h3 class="sde-blue bold text-center mb-0">{{$event->name}}</h3>
<p>{{$event->description}}</p> <p class="text-center mt-0">{{$event->date}}</p>
<a class="btn text-center btn-sde-blue btn-disabled" id="tilmeld">Tilmeld</a> <p class="text-center">{{$event->description}}</p>
@endforeach <a class="btn text-center btn-sde-blue" id="tilmeld">Tilmeld</a>
@endforeach
@else
<p class="text-center">Der er ingen aktiviteter!</p>
@endif
</main> </main>
@endsection @endsection

View File

@ -33,11 +33,11 @@
Reservationer Reservationer
</a> </a>
{{-- IKKE SLETTES!!!! --}} {{-- IKKE SLETTES!!!! --}}
{{-- <a href="#">--}} {{-- <a href="# ">--}}
{{-- <img src="{{URL::asset('/images/icons/Galleri.svg')}}" alt="Galleri">--}} {{-- <img src="{{URL::asset('/images/icons/Galleri.svg')}}" alt="Galleri">--}}
{{-- Galleri--}} {{-- Galleri--}}
{{-- </a>--}} {{-- </a>--}}
<a href="#"> <a href="{{ route("contacts.index") }}">
<img src="{{URL::asset('/images/icons/Kontoret.svg')}}" alt="Kontoret"> <img src="{{URL::asset('/images/icons/Kontoret.svg')}}" alt="Kontoret">
Kontoret Kontoret
</a> </a>