PHP code example of jonassiewertsen / statamic-livewire
1. Go to this page and download the library: Download jonassiewertsen/statamic-livewire library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jonassiewertsen / statamic-livewire example snippets
namespace App\Http\Livewire;
use Livewire\Component;
class Counter extends Component
{
public function render()
{
return view('livewire.counter');
}
}
use Livewire\Component;
class ShowContact extends Component
{
public $name;
public $email;
public function mount($contact)
{
$this->name = $contact->name;
$this->email = $contact->email;
}
...
}
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());
}
}
use Jonassiewertsen\Livewire\WithPagination;
class ShowArticles extends Component
{
use WithPagination;
protected function entries()
{
$entries = Entry::query()
->where('collection', 'articles')
->paginate(3);
return $this->withPagination('entries', $entries);
}
public function render()
{
return view('livewire.blog-entries', $this->entries());
}
}
namespace App\Livewire;
use Livewire\Component;
use Statamic\Entries\EntryCollection;
use Statamic\Entries\Entry;
class Foo extends Component
{
public EntryCollection $entries;
public Entry $entry;
// normal livewire stuff
}