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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -