To disable a global scope in Laravel Nova, you can use the withoutGlobalScope method provided by Eloquent. Here's how you can modify your code to disable the global scope:
use App\Models\YourModel; // Replace with your actual model class
public function indexQuery(NovaRequest $request, $query)
{
return $query->withoutGlobalScope('your_global_scope');
}
Replace 'your_global_scope' with the name of the global scope you want to disable. Make sure to replace YourModel with the actual model class that has the global scope.
If you want to disable the global scope for a specific relationship, you can use the withoutGlobalScopes method on the relationship query. Here's an example:
use App\Models\YourModel; // Replace with your actual model class
public function yourRelationship()
{
return $this->hasOne(YourModel::class)->withoutGlobalScopes();
}
Again, replace YourModel with the actual model class.
Remember to clear the Laravel Nova cache by running the following command:
php artisan nova:publish
This should disable the global scope and allow you to create the relationship from the resource.