<?php
|
|
|
|
namespace App\Http\Livewire\Collaborators\Associates;
|
|
|
|
use App\Associate;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class Index extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
/**
|
|
* The parameters that should sync with the URL query string
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $updatesQueryString = [
|
|
'search' => ['except' => '']
|
|
];
|
|
|
|
/** @var string */
|
|
public $orderColumn = 'created_at';
|
|
|
|
/** @var string */
|
|
public $orderDirection = 'DESC';
|
|
|
|
/** @var int */
|
|
public $perPage = 10;
|
|
|
|
/** @var string */
|
|
public $search;
|
|
|
|
public function mount()
|
|
{
|
|
$this->search = request()->query('search', $this->search);
|
|
}
|
|
|
|
public function updatingSearch()
|
|
{
|
|
$this->resetPage();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.collaborators.associates.index', [
|
|
'associates' => Associate::with('category')->where('name', 'LIKE', '%' . $this->search . '%')->orderBy($this->orderColumn, $this->orderDirection)->paginate($this->perPage),
|
|
]);
|
|
}
|
|
}
|