Skip to content

Update a table using Maatwebsite Excel Import based on condition #3064

Answered by Zubair-Iftikhar
noblemfd asked this question in Q&A
Discussion options

You must be logged in to vote

Using Laravel-5.8 and Maatwebsite-3.1, I have a table called employees (Employee).

class FirstEmployeeSheetImport implements ToModel, WithBatchInserts, WithHeadingRow, SkipsOnError, WithValidation, SkipsOnFailure
{
   use Importable, SkipsErrors, SkipsFailures;

   public function model(array $row)
   {           
      $this->department = $row['department'];        
      $employee_data = [
        'employee_code'                     => $row['employee_code'],
        'company_id'                        => Auth::user()->company_id,
        'email'                             => $row['official_email'],
        'department_id'                     => $this->getDepartment(),
     ];         …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by noblemfd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants