app/Http/Controllers/ServiceAdminController.php
/**
     *
     * Export enterprise's register to a CSV file.
     * 
     * @return Response
     * 
     */
Export enterprise's register to a CSV file.

@return Response
Export enterprise ' s register to a CSV file . @return Response
public function exportEnterpriseRegister()
    {
        $enterprises = Enterprise::orderBy('name')->get();
        $filename = 'empresas.csv';
        $handle = fopen($filename, 'w+');
        fputcsv($handle, array('Nome', 'Contato', 'Telefone', 'E-mail', 'Site', 'Endereço', 'Perfil'));
        foreach($enterprises as $enterprise) {
            fputcsv($handle, array($enterprise['name'], $enterprise['contact'], $enterprise['telephone'], $enterprise['email'], $enterprise['site'], $enterprise['address'], $enterprise['profile']));
        }
        fclose($handle);
        $headers = array(
            'Content-Type' => 'text/csv',
        );
        return Response::download($filename, 'empresas.csv', $headers);
    }
public function exportEnterpriseRegister ( ) { $ enterprises = Enterprise :: orderBy ( 'name' ) -> get ( ) ; $ filename = 'empresas.csv' ; $ handle = fopen ( $ filename , 'w+' ) ; fputcsv ( $ handle , array ( 'Nome' , 'Contato' , 'Telefone' , 'E-mail' , 'Site' , 'Endereço', Perfil') ) ; foreach ( $ enterprises as $ enterprise ) { fputcsv ( $ handle , array ( $ enterprise [ 'name' ] , $ enterprise [ 'contact' ] , $ enterprise [ 'telephone' ] , $ enterprise [ 'email' ] , $ enterprise [ 'site' ] , $ enterprise [ 'address' ] , $ enterprise [ 'profile' ] ) ) ; } fclose ( $ handle ) ; $ headers = array ( 'Content-Type' => 'text/csv' , ) ; return Response :: download ( $ filename , 'empresas.csv' , $ headers ) ; }
Export enterprise's register to a CSV file.
Export enterprise ' s register to a CSV file .