Searchable either name or barcode
What I am trying to do:
In my relationship manager, I have an action have a form field wherein I can type either the name or barcode of an equipment record and they show the same record with the same label, I want it to still display the name even if I searched the barcode
What I did:
I tried using this
https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-results
wherein I can indeed search by typing the barcode and it labels with the name
but I can't search by simply searching the name. Probably because the
I tried adding
My issue/the error:
I am unaware if its possible to do search both columns in a single field and how to do that.
I am amateur when it comes to php
Code:
In my relationship manager, I have an action have a form field wherein I can type either the name or barcode of an equipment record and they show the same record with the same label, I want it to still display the name even if I searched the barcode
What I did:
I tried using this
https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-results
wherein I can indeed search by typing the barcode and it labels with the name
but I can't search by simply searching the name. Probably because the
Equipment::where('barcode')I tried adding
where('barcode','name') but I get an error SQLSTATE[42000]: Syntax error My issue/the error:
I am unaware if its possible to do search both columns in a single field and how to do that.
I am amateur when it comes to php
Code:
Solution
Your initial approach was a good start, it was just missing the
This should search name and barcode, but only show name in the list.
orWhereThis should search name and barcode, but only show name in the list.