-
app/Models/Scopes/MediaScope.php
Open in GitHubuse Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Scope; class MediaScope implements Scope { public function apply(Builder $builder, Model $model): void { $builder->orderBy('order_column', 'asc'); } }
-
https://github.com/luadotsh/lua/blob/main/app/Models/Media.php
Open in GitHubuse App\Models\Scopes\MediaScope; use Spatie\MediaLibrary\MediaCollections\Models\Media as BaseMedia; class Media extends BaseMedia { // ... protected static function booted(): void { static::addGlobalScope(new MediaScope()); } // ... }