renamed income/expense
This commit is contained in:
		
							
								
								
									
										37
									
								
								app/Imports/Sales/Sheets/InvoiceItemTaxes.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								app/Imports/Sales/Sheets/InvoiceItemTaxes.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Imports\Sales\Sheets;
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
{
 | 
			
		||||
    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();
 | 
			
		||||
       }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user