Skip to content

Commit

Permalink
Collection order
Browse files Browse the repository at this point in the history
Sort Future models by commit_at
  • Loading branch information
pakomp committed Nov 24, 2017
1 parent 8d742f8 commit f35c300
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Models/Future.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ class Future extends Model
{
use SoftDeletes;

/**
* We always want our futures sorted by commit_at
*/
protected static function boot() {
parent::boot();
static::addGlobalScope('order', function (Builder $builder) {
$builder->orderBy('commit_at', 'asc');
});
}

/**
* The attributes that should be casted to native types.
*
Expand Down

0 comments on commit f35c300

Please sign in to comment.