How do you add a global scope to help sorting records by default in Laravel?
EloquentHere is an example of a simple global scope, added to the boot method, that will ensure that a User model is always sorted by `first_name`:
protected static function boot() { parent::boot(); static::addGlobalScope('order', function (Builder $builder) { $builder->orderBy('first_name'); }); } lang-php