-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Bug]: Export FromQuery double join statements in query. #4133
Comments
I would expect that it is running the query() twice and as laravels query builder is using classes, it will add the join twice as well. So try doing a clone public function query(){
return $this->query
->clone()
->select(['id'])
->join("products", "reviews.product_id", '=', "products.id");
}` |
How this issue end up? |
This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions. |
This is definitely a bug (also reported in #4140), but I managed to work around it by adding a check to see whether static $done = false;
if ($done) {
return $this->query;
}
$done = true;
//Now carry on making your modifications to `$query` |
Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?
What version of Laravel Excel are you using?
3.1.55
What version of Laravel are you using?
v10.48.7
What version of PHP are you using?
8.3.7
Describe your issue
I wrote a class implementing FromQuery and With Headings to use Exportable.
I used the __constructor to pass a Query from outside, which I am referencing in the query method.
This is working fine. At the moment, when I add a join to the query method, it adds it twice.
If I am not passing the query over the constructor, it's working. If I am adding the joins outside and than pass it its also working.
Call of the class
$query = Review::query(); return (new ExcelReviewExport($query))->download('reviews.xlsx');
`class ExcelReviewExport implements FromQuery, WithHeadings
{
use Exportable;
This is not stated in the documentation and maybe was never supposed to be used like this, but it would be nice if it worked. I will add the joins as a workaround outside of the class, so this is really low prior for me.
Thanks for the great work on this Package!
How can the issue be reproduced?
Create an ExcelExport Class with FromQuery.
Pass the query over to the constructor.
Add a join in the query method to the passed query.
What should be the expected behaviour?
Adding joins only once.
The text was updated successfully, but these errors were encountered: