SmartCane/laravel_app/app/Livewire/Searchable.php
Martin Folkerts 62b9942a53 wip
2024-03-12 12:09:29 +01:00

25 lines
486 B
PHP

<?php
namespace App\Livewire;
trait Searchable
{
public $search = '';
public function updatedSearchable($property)
{
if ($property === 'search') {
$this->resetPage();
}
}
protected function applySearch($query)
{
return $this->search === ''
? $query
: $query
->where('email', 'like', '%'.$this->search.'%')
->orWhere('number', 'like', '%'.$this->search.'%');
}
}