Ok, so I'm trying to execute a mysql query to join tables and return the results.
So, in my controller, I have an array of serviceIDs when print_r () looks like this:
Array
(
[0] => 50707
[1] => 50709
)
The name of this array is $ serviceIDS
So now I am calling a function from one of my models. This is the scope below:
$services = Services::getWatchListInfo($serviceIDS)->get();
This is the scope function in my model:
public function scopegetWatchListInfo($serviceIDS){
$services = DB::table('services')
->join('reviews','services.serviceID','=','reviews.serviceID')
->select('services.name','services.type','services.review_count_approved','reviews.escalate','reviews.average_rating')
->whereIn('serviceID',$serviceIDS);
return $services;
}
Okay, so this should get results from both my service and the review table, where the service ID is in the array.
Instead, I get the following error.
Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, object given, called in /Users/user/sites/informatics-2/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 311 and defined
Any ideas?