v0.10.19 - Added building name to reservation site

Fixed $eventsToDelete in EventController.php
This commit is contained in:
Anders 2020-08-31 14:04:02 +02:00
parent a6ffea7016
commit bccd00683f
3 changed files with 10 additions and 10 deletions

View File

@ -11,6 +11,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
date_default_timezone_set('Europe/Copenhagen');
class EventController extends Controller
{
@ -32,17 +33,15 @@ class EventController extends Controller
*/
public function index(Request $request)
{
$eventsToDelete = DB::table('events')
->where('events.date', '<=', date('Y-m-d H:i', strtotime('-1 day')))->get();
$eventsToDelete = Event::query()->get();
foreach ($eventsToDelete as $event)
{
DB::table('user_events')
->where('event_id', '=', $event->id)
->delete();
foreach ($eventsToDelete as $event) {
if (date('Y-m-d H:i', strtotime('-1 day')) >= date('Y-m-d H:i', strtotime($event->date))) {
UserEvent::query()->where('event_id', '=', $event->id)->delete();
$event->delete();
}
}
$events = Event::query()->orderBY('date' , 'asc')->paginate($request->input("limit", 20));

View File

@ -265,7 +265,7 @@ class WashingReservationController extends Controller
{
WashingReservation::query()->where('time', '<', date('Y-m-d H:i:s', strtotime('-1 hour')))->delete();
$reservations = WashingReservation::query()->where("user_id", "=", auth()->user()->id)->orderBY('time' , 'asc')->paginate($request->query("limit", 20));
$reservations = WashingReservation::query()->join('washing_machines', 'washing_machines.id', '=', 'washing_reservations.machine_id')->join('locations', 'locations.id', '=', 'washing_machines.location_id')->where("user_id", "=", auth()->user()->id)->orderBY('time' , 'asc')->paginate($request->query("limit", 20));
return Response::detect("washing-reservations.index", [ "reservations" => $reservations]);
}

View File

@ -15,7 +15,8 @@
<div class="reservation" style="margin: 0 32px 1.75rem 32px;">
<h3>{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}</h3>
<div class="row align-items-center">
<span style="font-size: 4vw"><b>{{__('msg.tid')}}:</b> {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y \k\l\. H:i') }}</span>
<span style="font-size: 4vw; white-space: pre-line;"><b>{{__('msg.tid')}}:</b> {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y \k\l\. H:i') }}
- {{ $reservation->name }}</span>
<form class="ml-auto" method="post" action="{{ route("washing-reservations.destroy", [ "washing_reservation" => $reservation ]) }}">
@csrf
@method("delete")