Closed antonkomarev closed 7 years ago
The only thing left to decide, is current methods should be placed in HasKeptFlagScope
or HasKeptFlagHelpers
trait.
public function scopeOnlyUnkeptOlderThanHours(Builder $builder, $hours)
{
return $builder->onlyUnkept()
->where(static::getCreatedAtColumn(), '<=', Carbon::now()->subHours($hours)->toDateTimeString());
}
Right now it's in HasKeptFlagScope
trait, but this is helper, not a global scope. Placed in scope because it's depends on onlyUnkept()
method and if Scope trait wouldn't be loaded by developer - this method will be broken.
Solutions:
Each flag has root trait
Has{Name}Flag
which will use:Has{Name}FlagScope
adds global scopes to flag (and global scope related methods).Has{Name}FlagHelpers
for additional flag methods.Has{Name}FlagBehavior
- used only in Kept flag to implement it's default behavior (model will be created withis_kept=false
and will change tois_kept=true
on first model update).