Laravel-Excel: [BUG] globalscopes are not applied on export

Prerequisites

Versions

  • PHP version: PHP 7.4.7 (cli) (built: Jun 12 2020 00:00:24) ( NTS )
  • Laravel version: Laravel Framework 7.17.2
  • Package version: 3.1.19

Description

package doesn’t respect the global-scopes on export ex.

protected static function booted()
    {
        static::addGlobalScope('latest_items', function (Builder $builder) {
            $builder->latest(
                $builder->qualifyColumn('created_at')
            );
        });
    }

query is correct ex.

select * from `requests` order by `requests`.`created_at` desc  

but the exported sheet is not sorted.

Steps to Reproduce

  • add data with different dates
  • add globalscope to ordeby
  • export the sheet via query

Expected behavior:

  • globalscopes should be respected.

Actual behavior:

  • sheet is not sorted according to globalscope.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

It would replace the query() method your have right now. Give it a go!

I’m not saying it isn’t. I’m trying to find out why it’s not being called.