FilamentF
Filament3y ago
Vp

Custom livewire in render-hook not working

I create a livewire page artisan make:livewire test, and inside test I assign variable like below
class Test extends Component
{
    public $query = 'abc';

    public function render()
    {
        return view('livewire.test');
    }
}

And in blade file
<div>
    {{ $query }} // this throw error

    <x-filament::input.wrapper suffix-icon="heroicon-m-globe-alt">
        <x-filament::input
            type="url"
            wire:model="query"
        />
    </x-filament::input.wrapper>
</div>

I create render hook and call this like
return $panel
  ->renderHook(
    'panels::global-search.before',
    fn (): View => view('livewire.test'),
  )

But I always get Undefined variable $query. What should be the problem?
Was this page helpful?