Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

36 lines (29 sloc) 782 Bytes
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use Livewire\WithPagination;
class ContactsTable extends Component
{
use WithPagination;
public $perPage = 10;
public $sortField;
public $sortAsc = true;
public $search = '';
public function sortBy($field)
{
if ($this->sortField === $field) {
$this->sortAsc = ! $this->sortAsc;
} else {
$this->sortAsc = true;
}
$this->sortField = $field;
}
public function render()
{
return view('livewire.contacts-table', [
'contacts' => \App\Contact::search($this->search)
->orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc')
->paginate($this->perPage),
]);
}
}
You can’t perform that action at this time.