Ad
Search In Subarray
I have arrays which I get so
$article_foundd = Article::all();
Array itself
"["meta_title"]=> string(5) "sport"
["meta_description"]=> string(4) "NEWS"
["meta_keyword"]=> string(7) "sport, olimp"
"["meta_title"]=> string(7) "climate"
["meta_description"]=> string(14) "Climate change"
["meta_keyword"]=> string(19) "climate,weather,rain"
"["meta_title"]=> string(7) "box"
["meta_description"]=> string(19) "box"
["meta_keyword"]=> string(7) "sport,box,roy,tyson"
I need that when a person entered “sport” in the search bar, then all articles related to sports would be displayed, for example.
Search all by meta_keywords
At the moment I have implemented a meta title, but I need to use the keys.
$q = Input::get ( 'q' );
$article_found = Article::where('meta_title','LIKE','%'.$q.'%')->get();
if(count($article_found) > 0)
return view('blog.search')->withDetails($article_found)->with('details' =>$article_found);
Ad
Answer
Try this example query for searching items by field meta_keyword
$article_found = Article::where('meta_keyword','LIKE','%'.$q.'%')->get();
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad