Replies: 1 comment
-
I solved it this way ->searchable(
function ($query, $searchTerm) {
$query->whereHas('customer.user', function ($query) use ($searchTerm) {
$query->where('name', 'like', '%' . $searchTerm . '%');
})->orWhereHas('customer.user', function ($query) use ($searchTerm) {
$query->where('last_name', 'like', '%' . $searchTerm . '%');
})->orWhereHas('customer.user', function ($query) use ($searchTerm) {
$query->whereRaw("CONCAT(name, ' ', last_name) LIKE ?", ["%{$searchTerm}%"]);
})->orWhereHas('customer.user', function ($query) use ($searchTerm) {
$query->whereRaw("CONCAT(last_name, ' ', name) LIKE ?", ["%{$searchTerm}%"]);
});
}
) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I am using the Laravel Livewire Tables package, and I have a subscribers table that is related to a customers table, which in turn is related to a users table.
I want to lookup the subscriber's first and last name (which are stored in users) directly from my Livewire DataTable without using aliases, because with aliases my table either doesn't display or the lookup doesn't work.
This is what finally worked for me (at least the table is rendered and displayed correctly):
This “works” only to view the data, but when I enter a first name + last name, it does not bring me the result. And the data exists in the database :S
Any tips, advice, or best practices are very welcome! Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions