laravel query where in comma delimited string

Using Laravel to check if a value is in an array stored as comma delimited string, example string stored in mysql table 1,14,15,20,25

So I’m trying to add comma’s at the start and end to search appropriately

$query = Profile::whereRaw("',' + cf_profile.sub_category_id + ',' LIKE '%,$sub_category->sub_category_id,%'");

Can anyone let me know where I’m going wrong here, as it’s returning no results.

Source: laravel

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.