This commit is contained in:
Neerholt 2020-08-04 15:29:18 +02:00
commit 4f1ff3a823
33 changed files with 45 additions and 634 deletions

View File

@ -1,34 +0,0 @@
<?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;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class Album extends Model
{
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [
'name'
];
public function parentAlbum()
{
return $this->belongsTo('App\Album');
}
public function images()
{
return $this->hasMany('App\Image');
}
public function videos()
{
return $this->hasMany('App\Video');
}
}

View File

@ -1,16 +0,0 @@
<?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;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class CalendarDate extends Model
{
//
}

View File

@ -1,17 +0,0 @@
<?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;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class CalendarEvent extends Model
{
//
}

View File

@ -1,25 +0,0 @@
<?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;
//allows the use of Model library
use Illuminate\Database\Eloquent\Model;
//Class of which should extend Model Library
class ExternalLink extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
//protected variable which contains name of database field(s) to be filled.
protected $fillable = [
'name', "link"
];
}

View File

@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class Guide extends Model
{
protected $fillable = [
'name', 'guideArticles'
'name', 'guide_articles'
];
}

View File

@ -1,85 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Album;
use Illuminate\Http\Request;
class AlbumController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Album $album
* @return \Illuminate\Http\Response
*/
public function show(Album $album)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Album $album
* @return \Illuminate\Http\Response
*/
public function edit(Album $album)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Album $album
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Album $album)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Album $album
* @return \Illuminate\Http\Response
*/
public function destroy(Album $album)
{
//
}
}

View File

@ -1,130 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\ExternalLink;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class ExternalLinkController extends Controller
{
function __construct()
{
$this->middleware([ "auth" ]);
$this->middleware("permission:link.external.list")->only("index");
$this->middleware("permission:link.external.create")->only(["create", "store"]);
$this->middleware("permission:link.external.show")->only("show");
$this->middleware("permission:link.external.edit")->only(["edit", "update"]);
$this->middleware("permission:link.external.delete")->only("destroy");
}
/**
* Display a listing of the resource.
*
* @param Request $request
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
$externalLink = ExternalLink::query()->paginate($request->input("limit", 20));
return Response::detect("external-links.index", [ "links" => $externalLink ]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function create()
{
return Response::detect("external-links.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)
{
$requestBody = $request->validate([
"name" => "required|max:255",
"link" => "required|max:255"
]);
$externalLink = new ExternalLink($requestBody);
$saved = $externalLink->save();
if(!$saved){
return Response::detect("external-links.store");
}else{
$externalLink = ExternalLink::query()->paginate($request->input("limit", 20));
return Response::detect("external-links.index", ['links' => $externalLink]);
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
return Response::detect("external-links.show", [ "link" => $id]);
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$link = ExternalLink::find($id);
return Response::detect("external-links.edit", ["link" => $link]);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$data = $request->all();
$link = ExternalLink::find($id);
$link->update($data);
$saved = $link->save();
if(!$saved){
return Response::detect("external-links.update", [ "link" => $link]);
}else{
$externalLink = ExternalLink::query()->paginate($request->input("limit", 20));
return Response::detect("external-links.index", ['links' => $externalLink]);
}
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$link = ExternalLink::find($id);
$link->delete();
return redirect()->route("external-links.index");
}
}

View File

@ -57,7 +57,7 @@ class GuideController extends Controller
//Me no sure what to store mester big smoke :)
$requestGuide = $request->validate([
"name" => "required|max:255",
"guideArticles" => "required",
"guide_articles" => "required",
]);
$guide = new Guide($requestGuide);
@ -105,7 +105,7 @@ class GuideController extends Controller
{
$data = $request->validate([
"name" => "required|max:255",
"guideArticles" => "required",
"guide_articles" => "required",
]);
$guidee = Guide::query()->where("id", "=", $guide->id)->first();

View File

@ -233,11 +233,32 @@ class UserController extends Controller
$user = User::query()->where('email', '=', $request->email)->first();
if($user == null){
return redirect()->back();
return redirect()->back()->with('errornosuchuser', '<p>Denne email findes ikke i systemet!</p>');
}
//Send email
//TODO: Implement mail.
$email = $user->email;
$pswd = "";
//Generate password
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$n = 6;
$randomString = '';
for ($i = 0; $i < $n; $i++) {
$index = rand(0, strlen($characters) - 1);
$randomString .= $characters[$index];
}
$pswd = $randomString;
$user->setPasswordAttribute($pswd);
$user->update();
$subject = "SDE Skolehjem reset password";
$msg = "Hej " . $user->name_first . " ". $user->name_last . ".\n\nDin adgangskode er nu: " . $pswd;
mail($email, $subject, $msg);
return redirect()->route('users.login');
}

View File

@ -67,15 +67,13 @@ class WashingReservationController extends Controller
$machineReservation = new WashingReservation($data);
$machineReservation->user_id = auth()->user()->id;
$machineReservation->save();
$saved = $machineReservation->save();
$allMachineReservations = WashingReservation::query()->where('time', '=', $request->time)->where('machine_id', '=', $request->machine_id)->get();
if (!$saved) {
return Response::detect("washing-reservations.store", [
"washing_reservation" => $machineReservation
]);
if (count($allMachineReservations) > 0) {
return redirect()->route("washing-reservations.create", ["washing_reservation" => $machineReservation])->with('ReservationExists', '<p class="text-center"><b>Der findes allerede en reservation til denne tid, men denne vaskemaskine!</b></p>');
} else {
$machineReservation->save();
$reservations = WashingReservation::query()->paginate($request->input("limit", 20));
return redirect()->route('washing-reservations.appindex', ["reservations" => $reservations]);
@ -174,7 +172,7 @@ class WashingReservationController extends Controller
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);
}

View File

@ -1,34 +0,0 @@
<?php
//Migrations acts as a version control for the database allowing you to modify the app's database schema
//allows use of necessary libraries
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View File

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

View File

@ -1,33 +0,0 @@
<?php
//Migrations acts as a version control for the database allowing you to modify the app's database schema
//allows use of necessary libraries
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCalendarDates extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('calendar_dates', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('calendar_dates');
}
}

View File

@ -1,33 +0,0 @@
<?php
//Migrations acts as a version control for the database allowing you to modify the app's database schema
//allows use of necessary libraries
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCalendarEvents extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('calendar_events', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('calendar_events');
}
}

View File

@ -1,35 +0,0 @@
<?php
//Migrations acts as a version control for the database allowing you to modify the app's database schema
//allows use of necessary libraries
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateExternalLinks extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('external_links', function (Blueprint $table) {
$table->id();
$table->string("name");
$table->string("link");
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('external_links');
}
}

View File

@ -1,34 +0,0 @@
<?php
//Migrations acts as a version control for the database allowing you to modify the app's database schema
//allows use of necessary libraries
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAlbumsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('albums', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->foreignId('user_id')->constrained();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('albums');
}
}

View File

@ -19,10 +19,9 @@ class CreateResourceExtension extends Migration
$table->id();
$table->string("extension", 60)->unique();
$table->text("description");
$table->unsignedInteger("resource_category_id");
$table->timestamps();
$table->foreign("resource_category_id")->references("id")->on("resource_categories");
$table->foreignid("resource_category_id")->constrained("resource_categories", "id");
});
}

View File

@ -18,10 +18,9 @@ class CreateResource extends Migration
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");
$table->foreignid("extension_id")->constrained("resource_extensions", "id");
});
}

View File

@ -15,13 +15,11 @@ class CreateUserEventsTable extends Migration
{
Schema::create('user_events', function (Blueprint $table) {
$table->id();
$table->integer("user_id");
$table->integer("event_id");
$table->timestamps();
$table->foreign("user_id")->references("id")->on("users");
$table->foreign("event_id")->references("id")->on("events");
$table->foreignid("user_id")->constrained("users", "id");
$table->foreignid("event_id")->constrained("events", "id");
});
}

View File

@ -17,7 +17,7 @@ class CreateGuidesTable extends Migration
$table->id();
$table->timestamps();
$table->string('name');
$table->longText('guideArticles');
$table->longText('guide_articles');
});
}

View File

@ -1,22 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Link - Opret
@endsection
@section("path")
<a href="{{ route('external-links.create') }}" class="text-white">Opret Link</a> /
@endsection
@section("content")
<h1>Opret Link:</h1>
<form method="post" action="{{ route("external-links.store") }}">
@csrf
<label for="title">Titel:</label>
<input type="text" name="name" id="title" required>
<label for="link">Linket:</label>
<input type="text" name="link" id="link" required>
<input type="submit" class="btn btn-dark text-white" value="Opret">
</form>
@endsection

View File

@ -1,13 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Link - Fjern
@endsection
@section("path")
<a href="{{ route('external-links.delete') }}" class="text-white">Fjern Link</a> /
@endsection
@section("content")
@endsection

View File

@ -1,23 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Link - Rediger
@endsection
@section("path")
<a href="{{route('external-links.edit', ['external_link' => $link])}}" class="text-white">Rediger Link</a> /
@endsection
@section("content")
<h1>Rediger Link:</h1>
<form method="post" action="{{route("external-links.update", ["external_link" => $link])}}">
@csrf
@method("PUT")
<label for="title">Titel:</label>
<input value="{{$link->name}}" type="text" name="name" id="title" required>
<label for="link">Linket:</label>
<input value="{{$link->link}}" type="text" name="link" id="link" required>
<input type="submit" class="btn btn-dark text-white" value="Rediger">
</form>
@endsection

View File

@ -1,40 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Link - Vis
@endsection
@section("path")
<a href="{{ route('external-links.index') }}" class="text-white">Vis Link</a> /
@endsection
@section("content")
<div class="row align-items-center">
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('external-links.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Ektern Link</a>
</div>
<table class="tbl mt-2">
<tr>
<th>Title</th>
<th>Link</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>
</tr>
@foreach($links as $link)
<tr>
<td>{{$link->name}}</td>
<td><a href="{{$link->link}}">{{$link->link}}</td>
<td><a href="{{ route("external-links.edit", [ "external_link" => $link ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td><form method="post" action="{{ route("external-links.destroy", [ "external_link" => $link ]) }}" class="w-100 nostyle">
@csrf
@method("delete")
<button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr>
@endforeach
</table>
{{ $links->links() }}
@endsection

View File

@ -1,14 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Link - Opret
@endsection
@section("path")
<a href="{{ route('external-links.create') }}" class="text-white">Opret External Link</a> /
@endsection
@section("content")
Link blev (ikke) oprettet.
@endsection

View File

@ -1,14 +0,0 @@
@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
link - Rediger
@endsection
@section("path")
<a href="{{ route('external-links.edit', ["external_link" => $link]) }}" class="text-white">External link</a> /
@endsection
@section("content")
Din link blev (ikke) redigeret.
@endsection

View File

@ -21,7 +21,7 @@
@csrf
<label for="title">Titel guiden</label>
<input type="text" name="name" id="title" required>
<textarea name="guideArticles" id="editor"></textarea>
<textarea name="guide_articles" id="editor"></textarea>
<input type="submit" class="btn btn-dark text-white" value="Opret">
</form>

View File

@ -23,7 +23,7 @@
<label for="title">Navn</label>
<input value="{{$guide->name}}" type="text" name="name" id="title" required>
<label for="editor">Vejledning</label>
<textarea name="guideArticles" id="editor">{{$guide->guideArticles}}</textarea>
<textarea name="guide_articles" id="editor">{{$guide->guideArticles}}</textarea>
<input type="submit" class="btn btn-dark text-white" value="Rediger">
</form>

View File

@ -29,9 +29,6 @@
<div class="segment">
<h3 class="text-white"><a href="{{ route("washing-reservations.index") }}" class="text-white"><i class="fa fa-link"></i><span style="margin-left: 4px;">Reservationer</span></a></h3>
</div>
<div class="segment">
<h3 class="text-white"><a href="{{ route("external-links.index") }}" class="text-white"><i class="fa fa-link"></i><span style="margin-left: 4px;">Eksterne Links</span></a></h3>
</div>
<div class="segment">
<h3 class="text-white"><a href="{{ route("contacts.index") }}" class="text-white"><i class="fa fa-link"></i><span style="margin-left: 4px;">Kontakter</span></a></h3>
</div>

View File

@ -9,10 +9,11 @@
<div class="brand">
<img src="{{URL::asset('/images/logos/Logo-hvid.svg')}}" alt="Syddansk Erhvervsskole">
</div>
<form action="" method="post">
<form action="{{ route("users.forgot") }}" method="post">
@csrf
<input class="appinput" type="email" name="email" placeholder="Email" required>
<input class="btn btn-dark" type="submit" value="Send reset mail">
</form>
{!! session()->get("errornosuchuser") !!}
</main>
@endsection

View File

@ -14,7 +14,7 @@
<h1 class="text-center sde-blue mt-0">Vejledninger</h1>
@foreach($guides as $guide)
<h2 class="text-center sde-blue mt-0">{{ $guide->name }}</h2>
{!! $guide->guideArticles !!}
{!! $guide->guide_articles !!}
<hr class="w-100">
@endforeach
</main>

View File

@ -7,6 +7,7 @@
@section("content")
<main>
<h1 class="text-center sde-blue mb-0">Booking Liste</h1>
{!! session()->get('ReservationExists') !!}
<div class="col w-100 mt-auto">
<div class="calendar-container">
<div class="calendar-container__header">