bladestan icon indicating copy to clipboard operation
bladestan copied to clipboard

Add Livewire support

Open jamesRUS52 opened this issue 1 year ago • 3 comments

the blade can access the public property of the livewire component without having to specify it as a parameter for "view" helper in the "render" method? like so

public $foo = 'bar';
public function render()
{
    return view('custom-livewire');
}

in blade {{ $foo }}

Too many like this for each livewire component

Line app/Http/Requests/Requests/Livewire/View/ActionsLivewire.php


29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.
29 Variable $foo might not be defined.


jamesRUS52 avatar Jun 08 '23 10:06 jamesRUS52

This also holds true for components, but you can workaround it by explicitly providing the variables.

public $foo = 'bar';
public function render()
{
    return view('custom-livewire', [
        'foo' => $this->foo,
    ]);
}

On that note I would also suggest that you use $this->view() rather then view() or the context will be unclear since it will be using reflection to detect and copy the properties.

AJenbo avatar Jun 08 '23 11:06 AJenbo

Any news on whether this could be solved more elegantly with Livewire v3? 🤞

johnbacon avatar Dec 20 '23 21:12 johnbacon

Is there some change that makes you think it would?

AJenbo avatar Dec 21 '23 03:12 AJenbo