fixed export pagination issue
This commit is contained in:
parent
e4743947eb
commit
af990972b9
|
|
@ -5,6 +5,7 @@ namespace App\Abstracts;
|
||||||
use Akaunting\Sortable\Traits\Sortable;
|
use Akaunting\Sortable\Traits\Sortable;
|
||||||
use App\Events\Common\SearchStringApplied;
|
use App\Events\Common\SearchStringApplied;
|
||||||
use App\Events\Common\SearchStringApplying;
|
use App\Events\Common\SearchStringApplying;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use App\Traits\DateTime;
|
use App\Traits\DateTime;
|
||||||
use App\Traits\Owners;
|
use App\Traits\Owners;
|
||||||
use App\Traits\Sources;
|
use App\Traits\Sources;
|
||||||
|
|
@ -161,7 +162,9 @@ abstract class Model extends Eloquent implements Ownable
|
||||||
$limit = (int) $request->get('limit', setting('default.list_limit', '25'));
|
$limit = (int) $request->get('limit', setting('default.list_limit', '25'));
|
||||||
$offset = $page ? ($page - 1) * $limit : 0;
|
$offset = $page ? ($page - 1) * $limit : 0;
|
||||||
|
|
||||||
$query->offset($offset)->limit($limit);
|
if (! $this instanceof WithParentSheet && count((array) $ids) < $limit) {
|
||||||
|
$query->offset($offset)->limit($limit);
|
||||||
|
}
|
||||||
|
|
||||||
return $query->cursor();
|
return $query->cursor();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ namespace App\Exports\Banking\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Banking\Transaction as Model;
|
use App\Models\Banking\Transaction as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
class RecurringTransactions extends Export implements WithColumnFormatting
|
class RecurringTransactions extends Export implements WithColumnFormatting, WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,10 @@ namespace App\Exports\Common\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Http\Requests\Common\ItemTax as Request;
|
use App\Http\Requests\Common\ItemTax as Request;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use App\Models\Common\ItemTax as Model;
|
use App\Models\Common\ItemTax as Model;
|
||||||
|
|
||||||
class ItemTaxes extends Export
|
class ItemTaxes extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public $request_class = Request::class;
|
public $request_class = Request::class;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\Bills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentHistory as Model;
|
use App\Models\Document\DocumentHistory as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class BillHistories extends Export
|
class BillHistories extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\Bills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItemTax as Model;
|
use App\Models\Document\DocumentItemTax as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class BillItemTaxes extends Export
|
class BillItemTaxes extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\Bills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItem as Model;
|
use App\Models\Document\DocumentItem as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class BillItems extends Export
|
class BillItems extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\Bills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentTotal as Model;
|
use App\Models\Document\DocumentTotal as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class BillTotals extends Export
|
class BillTotals extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ namespace App\Exports\Purchases\Bills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Banking\Transaction as Model;
|
use App\Models\Banking\Transaction as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
class BillTransactions extends Export implements WithColumnFormatting
|
class BillTransactions extends Export implements WithColumnFormatting, WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\RecurringBills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentHistory as Model;
|
use App\Models\Document\DocumentHistory as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringBillHistories extends Export
|
class RecurringBillHistories extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\RecurringBills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItemTax as Model;
|
use App\Models\Document\DocumentItemTax as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringBillItemTaxes extends Export
|
class RecurringBillItemTaxes extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\RecurringBills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItem as Model;
|
use App\Models\Document\DocumentItem as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringBillItems extends Export
|
class RecurringBillItems extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Purchases\RecurringBills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentTotal as Model;
|
use App\Models\Document\DocumentTotal as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringBillTotals extends Export
|
class RecurringBillTotals extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ namespace App\Exports\Purchases\RecurringBills\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\Document as Model;
|
use App\Models\Document\Document as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
class RecurringBills extends Export implements WithColumnFormatting
|
class RecurringBills extends Export implements WithColumnFormatting, WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Sales\Invoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentHistory as Model;
|
use App\Models\Document\DocumentHistory as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class InvoiceHistories extends Export
|
class InvoiceHistories extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Sales\Invoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItemTax as Model;
|
use App\Models\Document\DocumentItemTax as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class InvoiceItemTaxes extends Export
|
class InvoiceItemTaxes extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Sales\Invoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItem as Model;
|
use App\Models\Document\DocumentItem as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class InvoiceItems extends Export
|
class InvoiceItems extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ namespace App\Exports\Sales\Invoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentTotal as Model;
|
use App\Models\Document\DocumentTotal as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class InvoiceTotals extends Export
|
|
||||||
|
class InvoiceTotals extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ namespace App\Exports\Sales\Invoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Banking\Transaction as Model;
|
use App\Models\Banking\Transaction as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
class InvoiceTransactions extends Export implements WithColumnFormatting
|
class InvoiceTransactions extends Export implements WithColumnFormatting, WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Sales\RecurringInvoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentHistory as Model;
|
use App\Models\Document\DocumentHistory as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringInvoiceHistories extends Export
|
class RecurringInvoiceHistories extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Sales\RecurringInvoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItemTax as Model;
|
use App\Models\Document\DocumentItemTax as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringInvoiceItemTaxes extends Export
|
class RecurringInvoiceItemTaxes extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Sales\RecurringInvoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentItem as Model;
|
use App\Models\Document\DocumentItem as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringInvoiceItems extends Export
|
class RecurringInvoiceItems extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,9 @@ namespace App\Exports\Sales\RecurringInvoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\DocumentTotal as Model;
|
use App\Models\Document\DocumentTotal as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
|
|
||||||
class RecurringInvoiceTotals extends Export
|
class RecurringInvoiceTotals extends Export implements WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@ namespace App\Exports\Sales\RecurringInvoices\Sheets;
|
||||||
|
|
||||||
use App\Abstracts\Export;
|
use App\Abstracts\Export;
|
||||||
use App\Models\Document\Document as Model;
|
use App\Models\Document\Document as Model;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||||
|
|
||||||
class RecurringInvoices extends Export implements WithColumnFormatting
|
class RecurringInvoices extends Export implements WithColumnFormatting, WithParentSheet
|
||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Interfaces\Export;
|
||||||
|
|
||||||
|
interface WithParentSheet
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Models\Setting;
|
||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
use App\Builders\Category as Builder;
|
use App\Builders\Category as Builder;
|
||||||
use App\Models\Document\Document;
|
use App\Models\Document\Document;
|
||||||
|
use App\Interfaces\Export\WithParentSheet;
|
||||||
use App\Relations\HasMany\Category as HasMany;
|
use App\Relations\HasMany\Category as HasMany;
|
||||||
use App\Scopes\Category as Scope;
|
use App\Scopes\Category as Scope;
|
||||||
use App\Traits\Categories;
|
use App\Traits\Categories;
|
||||||
|
|
@ -240,7 +241,9 @@ class Category extends Model
|
||||||
$limit = (int) $request->get('limit', setting('default.list_limit', '25'));
|
$limit = (int) $request->get('limit', setting('default.list_limit', '25'));
|
||||||
$offset = $page ? ($page - 1) * $limit : 0;
|
$offset = $page ? ($page - 1) * $limit : 0;
|
||||||
|
|
||||||
$query->offset($offset)->limit($limit);
|
if (! $this instanceof WithParentSheet && count((array) $ids) < $limit) {
|
||||||
|
$query->offset($offset)->limit($limit);
|
||||||
|
}
|
||||||
|
|
||||||
return $query->cursor();
|
return $query->cursor();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue