-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
For some of our models we employ global scopes through the models boot() method. It is convenient, because those constrains do not need to repeated all over the application. Many relationship definitions etc.
e.g.
protected static function boot(): void
{
parent::boot();
self::addGlobalScope('published', static function (Builder $query): void {
$query->whereDate('from_date', '<=', Carbon::now())
->whereDate('to_date', '>=', Carbon::now());
});
self::addGlobalScope('active', static function (Builder $query): void {
$query->where('status', '=', 1);
});
}However JSON API faces a problem, "inactive" or "unpublished" records are not found - 404.
I do not see a way to pass withoutGlobalScopes() via schema.
What would be the suggested approach?
create a separate model without scopes for JSON API?
Metadata
Metadata
Assignees
Labels
No labels