YearScope.php 410 B

123456789101112131415161718
  1. <?php
  2. namespace App\Models\Scopes;
  3. use Illuminate\Database\Eloquent\Builder;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Scope;
  6. class YearScope implements Scope
  7. {
  8. /**
  9. * Apply the scope to a given Eloquent query builder.
  10. */
  11. public function apply(Builder $builder, Model $model): void
  12. {
  13. $builder->where($model->getTable() . '.year', year());
  14. }
  15. }