I got a column called fac that values can be a single number like 2 and also can be comma separated like 2,4,5
I want to get data from database via api. Also value can be a single or comma separated too. so user can search like these:
localhost/api/search {fac: 1}
Or
localhost/api/search {fac: 1,4,5}
I used find_in_set but look like it not working in this case:
$fac = request('fac');
->whereRaw("find_in_set({$fac}, fac)")->get();
If I run this localhost/api/search {fac: 1} it return nothing, if I run localhost/api/search {fac: 1,4,5} it give me error:
Syntax error or access violation: 1582 Incorrect parameter count in the call to native function 'find_in_set'
Goal:
If user search 1 it should return all data that contains 1, if search 1,7 should return all data that contains 1 and 7
