Laravel-Excel: [BUG] globalscopes are not applied on export
Prerequisites
- Checked if your Laravel Excel version is still supported: https://docs.laravel-excel.com/3.1/getting-started/support.html#supported-versions
- Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
- Checked that your issue isn’t already filed.
- Checked if no PR was submitted that fixes this problem.
- Filled in the entire issue template
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)
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.