I am getting Getting Call to a member function paginate() on array error in laravel with the following code
public static function search_query($query)
{
$tokenizeitem = array();
$tokenizeitem = queryarr($query);
//$tokenizeitem = $this->bbbootstrap->tokenizeStringIntoFTSWords($item);
$sql = "SELECT * FROM snippets WHERE MATCH(snippets_name,seo_description)
AGAINST (' ";
foreach ($tokenizeitem as $w) {
$sql .= '+' . $w . '* ';
}
$sql .= "' IN BOOLEAN MODE)";
$searchdata=DB::select( DB::raw($sql))->paginate(15);
return $searchdata;
}
The error is self explanatory:
your following code:
return an array and you can't call
paginate()
on array. So instead of this use:Laravel Raw Query Reference