added scope for collection export
This commit is contained in:
@@ -11,13 +11,7 @@ class Transactions extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('account', 'category', 'contact', 'document')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('account', 'category', 'contact', 'document')->collectForExport($this->ids, ['paid_at' => 'desc']);
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -12,18 +12,12 @@ class Transfers extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with(
|
||||
return Model::with(
|
||||
'expense_transaction',
|
||||
'expense_transaction.account',
|
||||
'income_transaction',
|
||||
'income_transaction.account'
|
||||
)->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
)->collectForExport($this->ids);
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class ItemTaxes extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('item', 'tax')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('item_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('item', 'tax')->collectForExport($this->ids, null, 'item_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class Items extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('category')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('category')->collectForExport($this->ids);
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -11,13 +11,7 @@ class Payments extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('account', 'bill', 'category', 'contact')->expense()->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('account', 'bill', 'category', 'contact')->expense()->collectForExport($this->ids, ['paid_at' => 'desc']);
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class BillHistories extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document')->bill()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class BillItemTaxes extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document', 'item', 'tax')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document', 'item', 'tax')->bill()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class BillItems extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document', 'item')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document', 'item')->bill()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class BillTotals extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('document')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document')->bill()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -11,13 +11,7 @@ class BillTransactions extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('account', 'category', 'contact', 'document')->expense()->isDocument()->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('account', 'category', 'contact', 'document')->expense()->isDocument()->collectForExport($this->ids, ['paid_at' => 'desc'], 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -11,13 +11,7 @@ class Bills extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::bill()->with('category')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('category')->bill()->collectForExport($this->ids, ['document_number' => 'desc']);
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class Vendors extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::type('vendor')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::vendor()->collectForExport($this->ids);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class Customers extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::type('customer')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::customer()->collectForExport($this->ids);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
|
||||
@@ -11,13 +11,7 @@ class Revenues extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('account', 'category', 'contact', 'invoice')->income()->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('account', 'category', 'contact', 'invoice')->income()->collectForExport($this->ids, ['paid_at' => 'desc']);
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class InvoiceHistories extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::invoice()->with('document')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document')->invoice()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class InvoiceItemTaxes extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::invoice()->with('document', 'item', 'tax')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document', 'item', 'tax')->invoice()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class InvoiceItems extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::invoice()->with('document', 'item')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document', 'item')->invoice()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class InvoiceTotals extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::invoice()->with('document')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('document')->invoice()->collectForExport($this->ids, null, 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace App\Exports\Sales\Sheets;
|
||||
|
||||
use App\Abstracts\Export;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Models\Document\Document;
|
||||
use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
@@ -13,13 +11,7 @@ class InvoiceTransactions extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::with('account', 'category', 'contact', 'document')->income()->isDocument()->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('document_id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('account', 'category', 'contact', 'document')->income()->isDocument()->collectForExport($this->ids, ['paid_at' => 'desc'], 'document_id');
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -11,13 +11,7 @@ class Invoices extends Export implements WithColumnFormatting
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::invoice()->with('category')->usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::with('category')->invoice()->collectForExport($this->ids, ['document_number' => 'desc']);
|
||||
}
|
||||
|
||||
public function map($model): array
|
||||
|
||||
@@ -9,13 +9,7 @@ class Categories extends Export
|
||||
{
|
||||
public function collection()
|
||||
{
|
||||
$model = Model::usingSearchString(request('search'));
|
||||
|
||||
if (!empty($this->ids)) {
|
||||
$model->whereIn('id', (array) $this->ids);
|
||||
}
|
||||
|
||||
return $model->cursor();
|
||||
return Model::collectForExport($this->ids);
|
||||
}
|
||||
|
||||
public function fields(): array
|
||||
|
||||
Reference in New Issue
Block a user