The package allows you to designate component properties as locked.
You can install the package via composer:
composer require aleksandro_del_piero/livewire-locked-properties
You need to add a trait to the component AleksandroDelPiero\LivewireLockedProperties\Traits\WithLockedLivewire;
To designate a property as protected, you must add it to a protected property $locked or declare a method locked().
namespace App\Http\Livewire;
use Livewire\Component;
use AleksandroDelPiero\LivewireLockedProperties\Traits\WithLockedLivewire;
class TestLivewire extends Component
{
use WithLockedLivewire;
public $name;
protected $locked = [
'name'
];
...
or a protected method 'locked'
namespace App\Http\Livewire;
use Livewire\Component;
use AleksandroDelPiero\LivewireLockedProperties\Traits\WithLockedLivewire;
class TestLivewire extends Component
{
use WithLockedLivewire;
public $name;
protected function locked(): array
{
return ['name'];
}
...
If a component has both a method and a property, the method will take precedence.
The MIT License (MIT). Please see License.md for more information.