Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ifrit's avatar

creating an export link

I'm trying to create a link that if you click on it, then it will export the values in the database to a pdf so that you can download it.

I'm using maatwebsite packages and I'm not getting anything. I just get taken to the route and I'm given a blank page with no errors or anything. My RsvpController.php

<?php namespace Modules\Rsvp\Http\Controllers;

use Pingpong\Modules\Routing\Controller;
use Modules\Rsvp\Models\Ceromony;
use Modules\Rsvp\Models\Reception;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Response;
use Excel;

class RsvpController extends Controller {
    public function export(){
        $data = Ceromony::get()->toArray();

        return Excel::create('rsvp', function($excel) use ($data){
            $excel->sheet('mySheet', function($sheet) use ($data){
                $sheet->fromArray($data);
            });
        })->download("pdf");
    }
}
    

my index.blade.php

<!-- This gets the admin template from app/modules/templates/views -->
@extends('templates::layouts.admin')
<!-- This inserts the content below into the template -->
@section('content')
    rsvp index blade blah

    {{ Html::link('admin/rsvp/export', 'Export', array('class' => 'btn btn-info')) }}
@stop

My routes.php

Route::group(['middleware' => ['web', 'auth'], 'namespace' => 'Modules\Rsvp\Http\Controllers'], function()
{
    Route::resource('admin/rsvp', 'RsvpController');
    Route::get('admin/rsvp/export', 'RsvpController@export');
});
0 likes
0 replies

Please or to participate in this conversation.