I have the following variable which holds an array :
$category = $request->get('catBox');
The variable has the following output :
array(2) { [0]=> string(7) "Zamalek" [1]=> string(4) "Ahly" }
How can I properly put the $category variable in the below query :
$Tagids = DB::table('tags')
->where('t_name', $category)
->pluck('id');
So that after that I will loop through the result to store a row for each result :
foreach($Tagids as $tagid){
$tagIns = new tagpost();
$tagIns->tag_id = $tagid;
$tagIns->save();
}
$categoryis it really an array? Add this ` dd($category);` after you get it from the request and make sure that it returns array of ids.->whereIn('t_name', array_values($category))