| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBooking\App\Http\Controllers; |
| 4 |
|
| 5 |
use FluentBooking\App\Models\CalendarSlot; |
| 6 |
use FluentBooking\Framework\Http\Request\Request; |
| 7 |
use FluentBooking\Framework\Support\Arr; |
| 8 |
|
| 9 |
class EventController extends Controller |
| 10 |
{ |
| 11 |
public function getEvent(Request $request, $eventId) |
| 12 |
{ |
| 13 |
$calendarEvent = CalendarSlot::with('calendar')->find($eventId); |
| 14 |
|
| 15 |
$eventHash = Arr::get($request->all(), 'event_hash'); |
| 16 |
|
| 17 |
if (!$calendarEvent && $eventHash) { |
| 18 |
$calendarEvent = CalendarSlot::with('calendar')->where('hash', $eventHash)->first(); |
| 19 |
} |
| 20 |
|
| 21 |
if (!$calendarEvent) { |
| 22 |
return $this->sendError([ |
| 23 |
'message' => __('Calendar Event not found', 'fluent-booking') |
| 24 |
]); |
| 25 |
} |
| 26 |
|
| 27 |
$calendarEvent->author_profile = $calendarEvent->getAuthorProfile(); |
| 28 |
|
| 29 |
$calendarEvent->calendar->author_profile = $calendarEvent->calendar->getAuthorProfile(); |
| 30 |
|
| 31 |
return [ |
| 32 |
'calendar_event' => $calendarEvent |
| 33 |
]; |
| 34 |
} |
| 35 |
|
| 36 |
} |
| 37 |
|