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

FireBlade's avatar

Pass search query parameters to Laravel Excel from Livewire component

How do I pass model search query parameters from Livewire component to Laravel Excel route ?

Livewire component:

public $search = '';

public function render()
    {
		'posts' =>Post::where('description', 'like', '%'.$this->search.'%')
            ->get()
	}

Laravel Excel route inside same Livewire component:


public function export() 
{
	
    return Excel::download(new PostsExport, 'posts.xlsx');
}

Setting public variables on the component will not work since the routes are stateless.

0 likes
1 reply

Please or to participate in this conversation.