Replies: 4 comments 2 replies
-
If you drop the |
Beta Was this translation helpful? Give feedback.
-
Oh my god.... Despite for me. Postman has a button "Send and Download" A lot of thanks. Work fine. |
Beta Was this translation helpful? Give feedback.
-
I have some comprehension errors because the query does not pass me correctly instead it returns all the elements.
if filter this with ray I get a 1 result for the query.
This return all CommandCenter instead one CommandCenter filtered by the query. Check code using ray()
Difference is that I send a That's is the problem? |
Beta Was this translation helpful? Give feedback.
-
Well I'll leave it here. I lost the solution. Saptie's QueryBuilder is not the same as Laravel's QueryBuilder. The result is that with the concern This allows me to work seamlessly with Spatie's QueryBuild $commandCenters = Spatie\QueryBuilder\QueryBuilder::for(CommandCenter::search($request->get('globalSearch')));
return (new CommandCentersExport($commandCenters->get()->toArray()))
->download(
"CommandCenters-".Carbon::now()->format('YmdHis').".$download",
); <?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
class CommandCentersExport implements FromArray, WithHeadings
{
use Exportable;
protected array $commandCenters;
public function __construct(array $commandCenters)
{
$this->commandCenters = $commandCenters;
}
public function headings(): array
{
if (count($this->commandCenters) > 0) {
return array_keys($this->commandCenters[0]);
} else {
return [];
}
}
public function array(): array
{
return $this->commandCenters;
}
} |
Beta Was this translation helpful? Give feedback.
-
I am working with an API that, due to the client's wishes, has led me to use Spatie/LaravelQueryBuilder
The client has asked me that in the frontend they have in the list views, the possibility of downloading, in Excel, CSV and PDF.
But of course, he wants it with the same abilities that the query build offers me:
sorted fields
filters,
And others.
That is, the client wants the export to be as it is on the screen, except for the pagination, of course.
Ok, QueryBuilder returns me an Illuminate\Database\Eloquent\Collection.
And with that I don't know how to apply it or if it is possible to an Export class for said model.
It's possible?
Because the only way I can see is to build back into the Export class, the complete query, which is hard.
Apreciate help
Beta Was this translation helpful? Give feedback.
All reactions