|
@@ -18,16 +18,21 @@ class AppointmentController extends Controller
|
|
|
{
|
|
|
public function events(Request $request)
|
|
|
{
|
|
|
- $proIds = $request->get('proIds');
|
|
|
+ $proIds = explode(',', $request->get('proIds'));
|
|
|
$start = $request->get('start');
|
|
|
$end = $request->get('end');
|
|
|
+ $clientId = $request->get('clientId');
|
|
|
$timeZone = $request->get('timeZone');
|
|
|
$appointments = Appointment
|
|
|
- ::whereIn('pro_id', explode(',', $proIds))
|
|
|
- ->where('status', '!=', 'COMPLETED')
|
|
|
+ ::where('status', '!=', 'COMPLETED')
|
|
|
->where('status', '!=', 'CANCELLED')
|
|
|
->where('start_time', '>=', $start)
|
|
|
->where('start_time', '<=', $end)
|
|
|
+ ->where(function ($query) use ($proIds, $clientId) {
|
|
|
+ $query
|
|
|
+ ->whereIn('pro_id', $proIds)
|
|
|
+ ->orWhere('client_id', '=', $clientId);
|
|
|
+ })
|
|
|
->get();
|
|
|
$events = [];
|
|
|
foreach ($appointments as $appointment) {
|
|
@@ -38,9 +43,11 @@ class AppointmentController extends Controller
|
|
|
"clientName" => $appointment->client->displayName(),
|
|
|
"appointmentUid" => $appointment->uid,
|
|
|
"clientUid" => $appointment->client->uid,
|
|
|
+ "proId" => $appointment->pro->id,
|
|
|
"proUid" => $appointment->pro->uid,
|
|
|
"start" => $this->convertToTimezone($appointment->start_time, $timeZone),
|
|
|
"end" => $this->convertToTimezone($appointment->end_time, $timeZone),
|
|
|
+ "clientOnly" => !in_array($appointment->pro->id, $proIds),
|
|
|
"editable" => true
|
|
|
];
|
|
|
}
|