Skip to content

Commit

Permalink
Merge pull request #52 from marcorieser/patch-1
Browse files Browse the repository at this point in the history
Mention `RestoreCurrentSite` trait in readme
  • Loading branch information
jonassiewertsen committed Mar 8, 2024
2 parents d098fc2 + b0818c5 commit ecc3ac3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ class ShowContact extends Component

The [Official Livewire documentation](https://livewire.laravel.com/docs/components#rendering-components)

### Multi-Site
When using Livewire in a Multi-Site context, the current site gets lost between requests. There is a trait (`\Jonassiewertsen\Livewire\RestoreCurrentSite`) to solve that. Just include it in your component and use `Site::current()` as you normally do.
```php
class ShowArticles extends Component
{
use \Jonassiewertsen\Livewire\RestoreCurrentSite;

protected function entries()
{
return Entry::query()
->where('collection', 'articles')
->where('site', Site::current())
->get();
}

public function render()
{
return view('livewire.blog-entries', $this->entries());
}
}
```

### Paginating Data
You can paginate results by using the WithPagination trait.

Expand Down

0 comments on commit ecc3ac3

Please sign in to comment.