In following pagination query i added the sorting code with OrderBy method but gives an error on first time page reload because there is no sort and order field is set there. how can i condition it set if exist or set null or else.
->select(array(
'to_jobs.rec_id',
'to_jobs.contarct_code',
'to_jobs.job_num',
'to_sites.site_name',
'to_sites.postcode',
'to_sites.site_id'
))
->orderBy(Request::get('sort'), Request::get('order'))
->leftjoin('to_sites', 'to_jobs.fk_site_id', '=', 'to_sites.site_id')
->paginate(10);