Conflicts:
	skolehjem/app/Http/Controllers/WashingReservationController.php
This commit is contained in:
frederikpyt 2020-08-04 16:52:42 +02:00
commit 64d1f785f9
15 changed files with 52 additions and 333 deletions

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

@ -146,6 +146,18 @@ class ContactController extends Controller
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/pencil.svg\" alt=\"Update\"></th>".
"<th style=\"width: 1em;\"><img class=\"w-100\" src=\"http://127.0.0.1:8000/images/icons/trashcan.svg\" alt=\"Delete\"></th>".
"</tr>";
if($request->isCheck === "navn")
$users = Contact::query()->where('contactname', 'LIKE',$request->search.'%')->get();
elseif ($request->isCheck === "titel")
$users = Contact::query()->where('title', 'LIKE',$request->search.'%')->get();
elseif ($request->isCheck === "email")
$users = Contact::query()->where('email', 'LIKE',$request->search.'%')->get();
elseif ($request->isCheck === "tf")
$users = Contact::query()->where('phone', 'LIKE',$request->search.'%')->get();
else
$users = DB::table('contacts')->where('contactname', 'LIKE',$request->search.'%')
->orWhere('title','LIKE', $request->search.'%')
->orWhere('phone','LIKE', $request->search.'%')
@ -170,7 +182,7 @@ class ContactController extends Controller
}
}else{
$output.='<tr>'.
'<td>Din søgning matchede ikke nogen personer</td>'.
'<td>Intet match</td>'.
'<td></td>'.
'<td></td>'.
'<td></td>'.

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

@ -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]);
@ -175,7 +173,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);
}
@ -232,7 +230,6 @@ class WashingReservationController extends Controller
'<td></td>'.
'<td></td>'.
'<td></td>'.
'<td></td>'.
'</tr>';
}
return Response($output);

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

@ -2,7 +2,7 @@
@extends("admin.layout.header")
@section("title")
Events - Vis
Kontakt - Vis
@endsection
@section("path")
@ -15,9 +15,18 @@
<form method="post" action="{{ route("users.store") }}">
@csrf
<input type="text" class="form-controller" id="search" name="search" placeholder="Søg på Navn, Email, Telefon"></input>
<input type="text" class="form-controller" id="search" name="search" placeholder="Søg på navn,titel,email,tf"></input>
</form>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="navn" value="navn">
<label for="navn">Navn</label>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="titel" value="titel">
<label for="efternavn">Titel</label>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="email" value="email">
<label for="efternavn">Email</label>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="tf" value="tf">
<label for="efternavn">Telefon</label>
<p></p>
</div>
@ -51,11 +60,13 @@
<script>
$('#search').on('keyup', function () {
$value = $(this).val();
$checkboxValue = $( "input:checked" ).val();
$.ajax({
type: 'get',
url: '{{route('contacts.search')}}',
data: {'search':$value},
data: {'search':$value, 'isCheck': $checkboxValue},
success:function (data) {
console.log($checkboxValue);
$('tbody').html(data);
},
error:function (data) {
@ -66,5 +77,22 @@
</script>
<script>
$(document).ready(function(){
$("input:checkbox").on('click', function() {
var $box = $(this);
if ($box.is(":checked")) {
var group = "input:checkbox[name='" + $box.attr("name") + "']";
$(group).prop("checked", false);
$box.prop("checked", true);
} else {
$box.prop("checked", false);
}
});
});
</script>
@endsection

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

@ -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

@ -15,14 +15,14 @@
<form method="post" action="{{ route("washing-reservations.store") }}">
@csrf
<input type="text" class="form-controller" id="search" name="search" placeholder="Søg på Navn, Telefon"></input>
<input type="text" class="form-controller" id="search" name="search" placeholder="Søg på vaskemaskine, tid"></input>
</form>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="vaskemaskine" value="vaskemaskine">
<label for="navn">Vaskemaskine</label>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="tidspunkt" value="tidspunkt">
<label for="efternavn">Tispunkt</label>
<label for="efternavn">Tidspunkt</label>
<input class="checkbox-inline" type="checkbox" name="checkbox" id="bruger" value="bruger">
<label for="email">Bruger</label>

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">