Skip to content
Discussion options

You must be logged in to vote

Thanks to a hint from @patrickbrouwers , this worked:
app\Imports\PricesImport.php

    <?php
    
    namespace App\Imports;
    
    use Maatwebsite\Excel\Concerns\ToArray;
    
    class PricesImport implements ToArray
    {
        private $data;

        public function __construct()
        {
            $this->data = [];
        }
        public function array(array $rows)
        {
            foreach ($rows as $row) {
                $this->data[] = array('sku' => $row[0], 'price' => $row[4]);
            }
        }

        public function getArray(): array
        {
            return $this->data;
        }
    }

And the call in the controller:

    <?php
    
    namespace App…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@hohanov
Comment options

@patrickbrouwers
Comment options

@hohanov
Comment options

@patrickbrouwers
Comment options

@hohanov
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by hohanov
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