/** * Display a listing of the resource. * * @return Response */ public function listItems() { $currUser = Auth::user()->id; $oQuery = Vacancy::join('categories', 'categories.id', '=', 'category_id')->join('users', 'users.id', '=', 'vacancies.user_id')->join('companies', 'companies.id', '=', 'vacancies.company_id')->join('cities', 'cities.id', '=', 'vacancies.city_id')->select('vacancies.id as id', 'title', 'vacancies.description', 'companies.id as company_id', 'companies.name as company_name', 'categories.name as category_name', 'users.name as user_name', 'categories.id as category_id', 'cities.name as city_name'); if (Auth::user()->is_admin == 0) { $aVacancies = $oQuery->where('vacancies.user_id', '=', $currUser); $aVacancies = $oQuery->paginate(10); } else { $aVacancies = $oQuery->paginate(10); } return View::make('/vacancy/list', array('aVacancies' => $aVacancies, 'currUser' => $currUser)); }