-
app/Models/OrderByNameScope.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Scope; use Illuminate\Database\Eloquent\Builder; class OrderByNameScope implements Scope { public function apply(Builder $builder, Model $model): void { $builder->orderBy('name'); } }
-
app/Models/Ingredients/Unit.php
Open in GitHubuse Illuminate\Database\Eloquent\Model; class Unit extends Model { // protected static function boot() { parent::boot(); static::addGlobalScope(new OrderByNameScope); } // }