I'm using laravel voyager with laravel 9 and I have an issue with the scope, the code is as follows:
public function scopeUser($query)
{ $products = DB::table('products')->select('id')->where('stakeholders_id', auth()->user()->id);
// dd($products);
$table = DB::table('product_variations')->whereIn('product_id',$products);
// dd($table);
return $table;
}
when I dd
the $table
variable I get the correct values needed when I add ->get()
at the end but when I remove both I get all the rows in the database when I need only the authenticated user's product variations, any ideas??
tray this