php - Filter on tag. Check if tag is in database string. Laravel -
i looking query check if $tag-variable (a string) part of string put in database through input field. user can add article en give tags separating comma. work , user can go article/{tag} url, not able show articles specific tag.
so need do? need check if $tag part of string that's in database (in "tags" column). tried , controller. don't know if contains()-function works.
here controller-code:
public function gettag($tag) { $articles = article::where('tags',contains('tags', $tag))->get(); return view("article.tagfilter")->with('articles',$articles); }
the right solution here :
$articles = article::where('tags', 'like', '%'.$tag.'%')->get();
thanks lamzozo!
Comments
Post a Comment