Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Scout support #4032

Merged
merged 12 commits into from Dec 8, 2023
Merged

Laravel Scout support #4032

merged 12 commits into from Dec 8, 2023

Conversation

Cellard
Copy link
Contributor

@Cellard Cellard commented Nov 17, 2023

This PR brings support of Laravel\Scout\Builder to FromQuery concern.

Users not infrequently want to export their search results. Laravel Scout is a good instrument for searching.

namespace App\Exports;

use App\Invoice;
use Maatwebsite\Excel\Concerns\FromQuery;

class InvoicesExport implements FromQuery
{
    public function query()
    {
        return Invoice::search('Search phrase');
    }
}

I write tests — for queued and direct writer.

  • Checked the codebase to ensure that your feature doesn't already exist.
  • Take note of the contributing guidelines.
  • Checked the pull requests to ensure that another person hasn't already submitted a fix.
  • Added tests to ensure against regression.

@Cellard Cellard marked this pull request as draft November 17, 2023 09:28
@Cellard Cellard marked this pull request as ready for review November 17, 2023 10:17
tests/Data/Stubs/Database/User.php Show resolved Hide resolved
tests/QueuedQueryExportTest.php Show resolved Hide resolved
src/Sheet.php Show resolved Hide resolved
src/Jobs/AppendPaginatedToSheet.php Outdated Show resolved Hide resolved
@patrickbrouwers patrickbrouwers merged commit 6d3c78c into SpartnerNL:3.1 Dec 8, 2023
16 checks passed
*/
protected function chunk($query)
{
if ($query instanceof \Laravel\Scout\Builder) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cellard this breaks for everyone not using Laravel scout but do use laravel Excel :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't break anything for me. I'm not using Laravel Scout, everything still works like expected. instanceof checks can run on non-existing classes.

joelharkes added a commit to joelharkes/Laravel-Excel that referenced this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants