Laravel passing variable to wherehas query
To pass a variable to closure you have to use the use() function
$products = Product::whereHas('natures', function($q) use($catname) { $q->where('nature_slug', '=', $catname); });
If you want provide string in variable, use this code
$catname = 'abc';
or declare abc constant
const abc = 123;