Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2368573ee7
|
@ -28,8 +28,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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +43,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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +61,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();
|
||||||
|
|
|
@ -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,23 +41,25 @@ 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);
|
||||||
|
@ -65,7 +72,7 @@ class WashingReservationController extends Controller
|
||||||
* 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 +87,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,12 +102,13 @@ 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);
|
||||||
|
@ -106,8 +117,8 @@ class WashingReservationController extends Controller
|
||||||
|
|
||||||
$machineReservation->save();
|
$machineReservation->save();
|
||||||
|
|
||||||
return Response::detect("washing-reservations.edit", [
|
return Response::detect("washing-reservations.update", [
|
||||||
"washingReservation" => $machineReservation
|
"washing_reservation" => $machineReservation
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,13 +126,15 @@ class WashingReservationController extends Controller
|
||||||
* 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class WashingReservation extends Model
|
class WashingReservation extends Model
|
||||||
{
|
{
|
||||||
//
|
protected $fillable = [
|
||||||
|
'time', 'machine'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -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');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -15,21 +15,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")
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue