Return the user's name raw on timetables
Diff
app/Http/Controllers/DJ/TimetableController.php | 8 +++++++-
app/Http/Controllers/Event/TimetableController.php | 11 ++++++++++-
2 files changed, 13 insertions(+), 6 deletions(-)
@@ -21,7 +21,7 @@
*/
public function getTimetable()
{
return view('dj.timetable', ['timetable' => $this->getJSONTimetable()]);
return view('dj.timetable', ['timetable' => $this->getJSONTimetable(false)]);
}
/**
@@ -131,9 +131,10 @@
/**
* Get the booked slots for this week in JSON format.
*
* @param bool $raw should we return raw html
* @return array
*/
public function getJSONTimetable()
public function getJSONTimetable($raw = true)
{
$week = Timetable::where('week', Carbon::now()->weekOfYear)->where('year', Carbon::now()->year)->get();
@@ -148,7 +149,8 @@
];
foreach ($week as $slot) {
$timetable[$slot->day][$slot->hour] = $slot->user->getDisplayName();
$timetable[$slot->day][$slot->hour] = $raw ? $slot->user->getDisplayName()->toHtml() :
$slot->user->getDisplayName();
}
return $timetable;
@@ -22,7 +22,7 @@
*/
public function getTimetable()
{
return view('events.timetable', ['timetable' => $this->getJSONTimetable()]);
return view('events.timetable', ['timetable' => $this->getJSONTimetable(false)]);
}
/**
@@ -181,9 +181,10 @@
/**
* Get the booked slots for this week in JSON format.
*
* @param bool $raw should we return the user's name in raw html
* @return array
*/
public function getJSONTimetable()
public function getJSONTimetable($raw = true)
{
$week = Event::where('week', Carbon::now()->weekOfYear)
->where('year', Carbon::now()->year)
@@ -203,7 +204,11 @@
foreach ($week as $slot) {
$type = $slot->type->name;
$timetable[$slot->day][$slot->hour] = $slot->user()->first()->getDisplayName() . " ({$type})";
$timetable[$slot->day][$slot->hour] = [
'name' => $raw ? $slot->user()->first()->getDisplayName()->toHtml() :
$slot->user()->first()->getDisplayName(),
'type' => $type
];
}
return $timetable;