public function mostrar_empresa()
 {
     $empresas = Empresa::orderBy('empresa_nombre')->paginate(4);
     return View::make('empresa.listaEmpresa', array('empresas' => $empresas));
 }
 public function getListadoEmpresasDT()
 {
     $empresa = new Empresa();
     if ($_GET['columns'][$_GET['order'][0]['column']]['data'] == "municipio" || $_GET['columns'][$_GET['order'][0]['column']]['data'] == "provincia") {
         $_GET['columns'][$_GET['order'][0]['column']]['data'] .= "_id";
     }
     if ($_GET['search']['value'] != '') {
         $empresas = $empresa->searchDT($_GET['columns'], $_GET['search']['value'])->orderBy($_GET['columns'][$_GET['order'][0]['column']]['data'], $_GET['order'][0]['dir'])->skip($_GET['start'])->take($_GET['length'])->get();
         $count = $empresa->searchDT($_GET['columns'], $_GET['search']['value'])->orderBy($_GET['columns'][$_GET['order'][0]['column']]['data'], $_GET['order'][0]['dir'])->skip($_GET['start'])->take($_GET['length'])->count();
     } else {
         $empresas = $empresa->orderBy($_GET['columns'][$_GET['order'][0]['column']]['data'], $_GET['order'][0]['dir'])->skip($_GET['start'])->take($_GET['length'])->get();
         $count = $empresa->count();
     }
     foreach ($empresas as $empresaN) {
         $provincia = $empresaN->provincia()->get();
         $municipio = $empresaN->municipio()->get();
         if (isset($provincia[0])) {
             $empresaN['provincia'] = $provincia[0]['NOMBRE'];
         } else {
             $empresaN['provincia'] = "-";
         }
         if (isset($municipio[0])) {
             $empresaN['municipio'] = $municipio[0]['NOMBRE'];
         } else {
             $empresaN['municipio'] = "-";
         }
         $empresaN['DT_RowId'] = "row_" . $empresaN['id'];
         $empresasNew[] = $empresaN;
     }
     if (isset($empresasNew)) {
         $return['data'] = $empresasNew;
         $return['recordsTotal'] = $empresa->count();
         $return['recordsFiltered'] = $count;
     } else {
         $return['data'] = '';
         $return['recordsTotal'] = 0;
         $return['recordsFiltered'] = 0;
     }
     $return['draw'] = $_GET['draw'];
     return $return;
 }