/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $reps = Rep::all(); $locations = DB::table('locations')->groupBy('state')->join('rep_location', 'locations.id', '=', 'rep_location.location_id')->get(); return view('representative/representative')->with(compact('reps', 'locations')); }