I’m using global scopes in a few of my models. I’d like to be able to dynamically remove the scoped logic at a controller level. My scope is applied to my PingtreeGroup model, and when I try to remove the global scope via my controller show method I get an error.
Too few arguments to function IlluminateDatabaseEloquentBuilder::withoutGlobalScope(), 0 passed
/**
* Display the specified resource.
*
* @return IlluminateHttpResponse
*/
public function show(Company $company, PingtreeGroup $pingtreeGroup)
{
$this->authorize('view', $pingtreeGroup);
$pingtreeGroup = $pingtreeGroup->withoutGlobalScope()->load([
'pingtree_group_entries',
'pingtree_group_entries.pingtree' => function ($query) {
$query->withCount('pingtree_entries');
},
'pingtree_group_entries.pingtree.pingtree_entries',
'pingtree_group_entries.pingtree.pingtree_entries.buyer_tier',
'pingtree_group_entries.pingtree.pingtree_entries.buyer_tier.buyer',
])->loadCount('pingtree_group_entries');
return new ApiSuccessResponse($pingtreeGroup);
}
What am I missing?