Skip to content

Commit

Permalink
391. add sorting for sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrakovich committed Jun 3, 2024
1 parent c9f0e4c commit df6ce53
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app/Models/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Models;

use App\Traits\AttributeFilterTrait;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

/**
Expand Down Expand Up @@ -33,6 +34,14 @@ class Size extends Model
*/
protected $connection = 'mysql';

/**
* Perform any actions required after the model boots.
*/
protected static function booted(): void
{
static::addGlobalScope('sort', fn (Builder $query) => $query->orderBy('value'));
}

/**
* Generate filter badge name
*/
Expand Down

0 comments on commit df6ce53

Please sign in to comment.