import chunk reading
This commit is contained in:
@@ -2,15 +2,11 @@
|
||||
|
||||
namespace App\Imports\Sales;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Common\Contact as Model;
|
||||
use App\Http\Requests\Common\Contact as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class Customers implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
class Customers extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
@@ -34,17 +30,4 @@ class Customers implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'customers',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ use App\Imports\Sales\Sheets\Invoices as Base;
|
||||
use App\Imports\Sales\Sheets\InvoiceItems;
|
||||
use App\Imports\Sales\Sheets\InvoiceItemTaxes;
|
||||
use App\Imports\Sales\Sheets\InvoiceHistories;
|
||||
use App\Imports\Sales\Sheets\InvoicePayments;
|
||||
use App\Imports\Sales\Sheets\InvoiceTotals;
|
||||
use App\Imports\Sales\Sheets\InvoiceTranactions;
|
||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||
|
||||
class Invoices implements WithMultipleSheets
|
||||
@@ -19,8 +19,8 @@ class Invoices implements WithMultipleSheets
|
||||
'invoice_items' => new InvoiceItems(),
|
||||
'invoice_item_taxes' => new InvoiceItemTaxes(),
|
||||
'invoice_histories' => new InvoiceHistories(),
|
||||
'invoice_payments' => new InvoicePayments(),
|
||||
'invoice_totals' => new InvoiceTotals(),
|
||||
'invoice_transactions' => new InvoiceTranactions(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
namespace App\Imports\Income;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class Revenues implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
class Revenues extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
@@ -21,6 +18,7 @@ class Revenues implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
$row['type'] = 'income';
|
||||
$row['paid_at'] = Date::parse($row['paid_at'])->format('Y-m-d H:i:s');
|
||||
|
||||
// Make reconciled field integer
|
||||
if (isset($row['reconciled'])) {
|
||||
@@ -34,17 +32,4 @@ class Revenues implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'revenues',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,43 +2,19 @@
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Sale\InvoiceHistory as Model;
|
||||
use App\Http\Requests\Sale\InvoiceHistory as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceHistories implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
class InvoiceHistories extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_histories',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,36 +2,13 @@
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Sale\InvoiceItemTax as Model;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceItemTaxes implements ToModel, WithHeadingRow, WithMapping
|
||||
class InvoiceItemTaxes extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_item_taxes',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,43 +2,19 @@
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Sale\InvoiceItem as Model;
|
||||
use App\Http\Requests\Sale\InvoiceItem as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceItems implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
class InvoiceItems extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_items',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoicePayments implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
$row['type'] = 'income';
|
||||
|
||||
// Make reconciled field integer
|
||||
if (isset($row['reconciled'])) {
|
||||
$row['reconciled'] = (int) $row['reconciled'];
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_payments',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,43 +2,19 @@
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Sale\InvoiceTotal as Model;
|
||||
use App\Http\Requests\Sale\InvoiceTotal as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class InvoiceTotals implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
class InvoiceTotals extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoice_totals',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
app/Imports/Sales/Sheets/InvoiceTranactions.php
Normal file
33
app/Imports/Sales/Sheets/InvoiceTranactions.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Banking\Transaction as Model;
|
||||
use App\Http\Requests\Banking\Transaction as Request;
|
||||
|
||||
class InvoiceTranactions extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
$row['type'] = 'income';
|
||||
|
||||
// Make reconciled field integer
|
||||
if (isset($row['reconciled'])) {
|
||||
$row['reconciled'] = (int) $row['reconciled'];
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
}
|
||||
@@ -2,43 +2,19 @@
|
||||
|
||||
namespace App\Imports\Sales\Sheets;
|
||||
|
||||
use App\Abstracts\Import;
|
||||
use App\Models\Sale\Invoice as Model;
|
||||
use App\Http\Requests\Sale\Invoice as Request;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
use Maatwebsite\Excel\Validators\Failure;
|
||||
|
||||
class Invoices implements ToModel, WithHeadingRow, WithMapping, WithValidation
|
||||
class Invoices extends Import
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new Model($row);
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$row['company_id'] = session('company_id');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return (new Request())->rules();
|
||||
}
|
||||
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
foreach ($failures as $failure) {
|
||||
$message = trans('messages.error.import_column', [
|
||||
'message' => $failure->errors()->first(),
|
||||
'sheet' => 'invoices',
|
||||
'line' => $failure->attribute(),
|
||||
]);
|
||||
|
||||
flash($message)->error()->important();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user