improved import mapping
This commit is contained in:
		@@ -15,13 +15,9 @@ class Customers extends Import
 | 
			
		||||
 | 
			
		||||
    public function map($row): array
 | 
			
		||||
    {
 | 
			
		||||
        $row['company_id'] = session('company_id');
 | 
			
		||||
        $row['type'] = 'customer';
 | 
			
		||||
        $row = parent::map($row);
 | 
			
		||||
 | 
			
		||||
        // Make enabled field integer
 | 
			
		||||
        if (isset($row['enabled'])) {
 | 
			
		||||
            $row['enabled'] = (int) $row['enabled'];
 | 
			
		||||
        }
 | 
			
		||||
        $row['type'] = 'customer';
 | 
			
		||||
 | 
			
		||||
        return $row;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ namespace App\Imports\Sales;
 | 
			
		||||
use App\Abstracts\Import;
 | 
			
		||||
use App\Models\Banking\Transaction as Model;
 | 
			
		||||
use App\Http\Requests\Banking\Transaction as Request;
 | 
			
		||||
use Jenssegers\Date\Date;
 | 
			
		||||
 | 
			
		||||
class Revenues extends Import
 | 
			
		||||
{
 | 
			
		||||
@@ -16,14 +15,9 @@ class Revenues extends Import
 | 
			
		||||
 | 
			
		||||
    public function map($row): array
 | 
			
		||||
    {
 | 
			
		||||
        $row['company_id'] = session('company_id');
 | 
			
		||||
        $row['type'] = 'income';
 | 
			
		||||
        $row['paid_at'] = Date::parse($row['paid_at'])->format('Y-m-d H:i:s');
 | 
			
		||||
        $row = parent::map($row);
 | 
			
		||||
 | 
			
		||||
        // Make reconciled field integer
 | 
			
		||||
        if (isset($row['reconciled'])) {
 | 
			
		||||
            $row['reconciled'] = (int) $row['reconciled'];
 | 
			
		||||
        }
 | 
			
		||||
        $row['type'] = 'income';
 | 
			
		||||
 | 
			
		||||
        return $row;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ namespace App\Imports\Sales\Sheets;
 | 
			
		||||
use App\Abstracts\Import;
 | 
			
		||||
use App\Models\Banking\Transaction as Model;
 | 
			
		||||
use App\Http\Requests\Banking\Transaction as Request;
 | 
			
		||||
use Jenssegers\Date\Date;
 | 
			
		||||
 | 
			
		||||
class InvoiceTranactions extends Import
 | 
			
		||||
{
 | 
			
		||||
@@ -16,14 +15,9 @@ class InvoiceTranactions extends Import
 | 
			
		||||
 | 
			
		||||
    public function map($row): array
 | 
			
		||||
    {
 | 
			
		||||
        $row['company_id'] = session('company_id');
 | 
			
		||||
        $row['type'] = 'income';
 | 
			
		||||
        $row['paid_at'] = Date::parse($row['paid_at'])->format('Y-m-d H:i:s');
 | 
			
		||||
        $row = parent::map($row);
 | 
			
		||||
 | 
			
		||||
        // Make reconciled field integer
 | 
			
		||||
        if (isset($row['reconciled'])) {
 | 
			
		||||
            $row['reconciled'] = (int) $row['reconciled'];
 | 
			
		||||
        }
 | 
			
		||||
        $row['type'] = 'income';
 | 
			
		||||
 | 
			
		||||
        return $row;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,6 @@ 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 Jenssegers\Date\Date;
 | 
			
		||||
 | 
			
		||||
class Invoices extends Import
 | 
			
		||||
{
 | 
			
		||||
@@ -14,15 +13,6 @@ class Invoices extends Import
 | 
			
		||||
        return new Model($row);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function map($row): array
 | 
			
		||||
    {
 | 
			
		||||
        $row['company_id'] = session('company_id');
 | 
			
		||||
        $row['invoiced_at'] = Date::parse($row['invoiced_at'])->format('Y-m-d H:i:s');
 | 
			
		||||
        $row['due_at'] = Date::parse($row['due_at'])->format('Y-m-d H:i:s');
 | 
			
		||||
 | 
			
		||||
        return $row;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function rules(): array
 | 
			
		||||
    {
 | 
			
		||||
        return (new Request())->rules();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user