MaatWeb/Excel +Laracast "Eloquent Techniques: Dedicated Query String Filtering"

Published 9 months ago by jngwny

After completing Laracast "Eloquent Techniques: Dedicated Query String Filtering"

then trying to export that filtered data with Maatweb/Excel

I get these errors when exporting (2/2) ErrorException

Undefined variable: events (View: /var/www/html/graphs/resources/views/traces/sortable.blade.php)


(1/2) ErrorException

Undefined variable: events in 155602786d9591ddb8b17b164a6a299cecbe9277.php (line 34)

my view

works ok and sorts but does not export here is my button in my view

href="{{ url('events/export') }}">Download Excel xls

Here is my controller

class SetTwoController extends Controller { public function index() { $events = SetTwo::paginate(15); return view('traces.trialindex',compact('events')); } // filter index public function indexsort(DataFilters $filters) { $events = SetTwo::filter($filters)->paginate(29); return view('traces.sortable',compact('events')); } // export query public function export() { Excel::create('Results', function($excel) { $excel->sheet('data',function($sheet) { $sheet->loadView('traces.sortable'); }); })->download('xls'); } }


tried this and it did not work public function export(DataFilters $filters) { $events = SetTwo::filter($filters)->paginate(29); Excel::create('Results', function($excel) { $excel->sheet('data',function($sheet) { $sheet->loadView('traces.sortable',array('events'=>$events)); }); })->download('xls'); }


using array function return all values in excel shreadhseet from export function "$sheet->fromArray($events);" (see entire controller) sort feature still works

my controller SetTwoController .txt

Please sign in or create an account to participate in this conversation.