public function download($type, $id, GeneratorListener $listener)
    {
        $model = Report::where('id', $id)->first();
        if (is_null($model)) {
            return $listener->downloadFailed();
        }
        $filename = snake_case(str_replace(['-', ':', ' '], '_', $model->name));
        switch ($type) {
            case 'pdf':
                $snappy = app('snappy.pdf.wrapper');
                $appKey = config('app.key');
                $ch     = curl_init();
                curl_setopt($ch, CURLOPT_URL, handles('antares::logger/view/' . $id . '/html'));
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_HTTPHEADER, ["generator:  {$appKey}"]);
                $html   = curl_exec($ch);
                curl_close($ch);
                $snappy->loadHTML($html);
                $return = $snappy->download($filename . '.pdf');
                break;
            default:
                $return = Response::make($model->html, '200', array(
                            'Content-Type'        => 'application/octet-stream',
                            'Content-Disposition' => 'attachment; filename="' . $filename . '.html'
                ));
                break;
        }
        return $return;
    }
public function download($type, $id, GeneratorListener $listener)
    {
        $model = Report::where('id', $id)->first();
        if (is_null($model)) {
            return $listener->downloadFailed();
        }
        $filename = snake_case(str_replace(['-', ':', ' '], '_', $model->name));
        switch ($type) {
            case 'pdf':
                $snappy = app('snappy.pdf.wrapper');
                $appKey = config('app.key');
                $ch     = curl_init();
                curl_setopt($ch, CURLOPT_URL, handles('antares::logger/view/' . $id . '/html'));
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_HTTPHEADER, ["generator:  {$appKey}"]);
                $html   = curl_exec($ch);
                curl_close($ch);
                $snappy->loadHTML($html);
                $return = $snappy->download($filename . '.pdf');
                break;
            default:
                $return = Response::make($model->html, '200', array(
                            'Content-Type'        => 'application/octet-stream',
                            'Content-Disposition' => 'attachment; filename="' . $filename . '.html'
                ));
                break;
        }
        return $return;
    }
public function download ( $ type , $ id , GeneratorListener $ listener ) { $ model = Report :: where ( 'id' , $ id ) -> first ( ) ; if ( is_null ( $ model ) ) { return $ listener -> downloadFailed ( ) ; } $ filename = snake_case ( str_replace ( [ '-' , ':' , ' ' ] , '_' , $ model -> name ) ) ; switch ( $ type ) { case 'pdf' : $ snappy = app ( 'snappy.pdf.wrapper' ) ; $ appKey = config ( 'app.key' ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , handles ( 'antares::logger/view/' . $ id . '/html' ) ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , [ "generator:  {$appKey}" ] ) ; $ html = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; $ snappy -> loadHTML ( $ html ) ; $ return = $ snappy -> download ( $ filename . '.pdf' ) ; break ; default : $ return = Response :: make ( $ model -> html , '200' , array ( 'Content-Type' => 'application/octet-stream' , 'Content-Disposition' => 'attachment; filename="' . $ filename . '.html' ) ) ; break ; } return $ return ; }
download report content

@param String $type
@param mixed $id
@param GeneratorListener $listener
download report content