isaacongoma liked this thread
Hi Lucas.
You should be able to use the conditional clause on the builder to achieve this.
Your use-case would be something like this (untested):
$users = User::when($this->search, function ($query) {
$query->search($this->search);
})
->orderBy($this->orderBy, $this->orderAsc ? 'ASC' : 'DESC')
->paginate($this->perPage);
lucasjose501, mrkalmdn liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community