You're browsing the documentation for an old version of Livewire. Consider upgrading your project to Livewire 3.x.

Be amazing at Livewire
with our in-depth screencasts.
Watch Now

Livewire offers an api for accessing dynamic properties. This is especially helpful for deriving properties from the database or another persistent store like a cache.

1class FooComponent extends Component
3 // Computed Property
4 public function getFooProperty()
5 {
6 return 'foo';
7 }

Now, you can access $this->foo from either the component's class or Blade view:

2 <span>{{ $this->foo }}</span>
Computed properties are cached for an individual Livewire request lifecycle. Meaning, if you call `$this->post` 5 times in a component's blade view, it won't make a separate database query every time.
Next Topic → Reference