<?php } else { ?> <p class="flash-message static error"><?php echo e($this->fatalError); ?> </p> <p><a href="<?php echo Backend::url('gatto/jobs/qualifications'); ?> " class="btn btn-default">Return to Qualifications list</a></p> <?php } ?> This is a query for the front-end, using Laravel query builder: it retrieves all the appointments for the logged in customer. <?php $this['appointments'] = Appointments::where('customer_id', '=', Auth::getUser()->id)->where('gatto_jobs_appointments.id', '=', $app_id)->join('gatto_jobs_jobs', 'gatto_jobs_appointments.job_id', '=', 'gatto_jobs_jobs.id')->join('users', 'gatto_jobs_appointments.customer_id', '=', 'users.id')->join('gatto_jobs_timeslots', 'gatto_jobs_timeslots.id', '=', 'time_slot')->get(['gatto_jobs_appointments.*', 'gatto_jobs_jobs.name as name', 'gatto_jobs_timeslots.name as timeslot', 'users.name as username'])->toArray(); ?> This is a simple Eloquent query to find a Job from an ID: <?php $this['selected_job'] = Job::where('id', '=', $this['job_id'])->first()->toArray();