Fix the events timetable
Diff
resources/views/dj/timetable.blade.php | 8 +++++---
resources/views/events/timetable.blade.php | 6 +++---
app/Http/Controllers/DJ/TimetableController.php | 6 +++++-
app/Http/Controllers/Event/TimetableController.php | 1 +
4 files changed, 12 insertions(+), 9 deletions(-)
@@ -21,19 +21,19 @@
@for ($i = 0; $i < 24; $i++)
<li>
{{ sprintf('%02d', $i) }}:00 -
@if(!isset($day[$i]) || ($day[$i] === auth()->user()->username || auth()->user()->isAdmin()))
@if(empty($day[$i]) || ($day[$i]['id'] === auth()->user()->userid || auth()->user()->isAdmin()))
<form action="{{ route('dashboard::dj::timetable.book') }}" method="post"
class="a-submit" style="display: inline">
{{ method_field(isset($day[$i]) ? 'delete' : 'put') }}
{{ method_field(!empty($day[$i]) ? 'delete' : 'put') }}
{{ csrf_field() }}
<input type="hidden" name="day" value="{{ $id }}">
<input type="hidden" name="hour" value="{{ $i }}">
<a href="javascript:void(0)" class="mdl-color-text--primary no-decoration">
{!! isset($day[$i]) ? $day[$i] : _('Unbooked') !!}
{!! !empty($day[$i]) ? $day[$i]['name'] : _('Unbooked') !!}
</a>
</form>
@else
{!! $day[$i] !!}
{!! $day[$i]['name'] !!}
@endif
</li>
@endfor
@@ -25,7 +25,7 @@
<a href="{{ route('dashboard::event::timetable.book', ['day' => $id, 'hour' => $i]) }}" class="mdl-color-text--primary no-decoration">
{{ _('Unbooked') }}
</a>
@elseif($day[$i] === auth()->user()->username || auth()->user()->isAdmin())
@elseif($day[$i]['id'] === auth()->user()->userid || auth()->user()->isAdmin())
<form action="{{ route('dashboard::event::timetable.unbook') }}" method="post"
class="a-submit" style="display: inline">
{{ method_field('delete') }}
@@ -33,11 +33,11 @@
<input type="hidden" name="day" value="{{ $id }}">
<input type="hidden" name="hour" value="{{ $i }}">
<a href="javascript:void(0)" class="mdl-color-text--primary no-decoration">
{!! $day[$i] !!}
{{ $day[$i]['name'] }} ({{ $day[$i]['type'] }})
</a>
</form>
@else
{!! $day[$i] !!}
{{ $day[$i]['name'] }} ({{ $day[$i]['type'] }})
@endif
</li>
@endfor
@@ -155,8 +155,10 @@
}
foreach ($week as $slot) {
$timetable[$slot->day][$slot->hour] = $raw ? $slot->user->getDisplayName()->toHtml() :
$slot->user->getDisplayName();
$timetable[$slot->day][$slot->hour] = [
'id' => $slot->user->userid,
'name' => $raw ? $slot->user->getDisplayName()->toHtml() : $slot->user->getDisplayName()
];
}
return $timetable;
@@ -211,6 +211,7 @@
$type = $slot->type->name;
$timetable[$slot->day][$slot->hour] = [
'id' => $slot->user()->first()->userid,
'name' => $raw ? $slot->user()->first()->getDisplayName()->toHtml() :
$slot->user()->first()->getDisplayName(),
'type' => $type