Flynsarmy / laravel-csv-seeder

Seed your database with CSV files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

array_pull() helper method deprecated

Splode opened this issue · comments

Overview

Issue when using laravel-csv-seeder in Laravel v7.

Expected Behavior

Expect to seed database using csv seeder.

Actual Behavior

Receive the following error when trying to seed with artisan migrate --seed:

 Call to undefined function Flynsarmy\CsvSeeder\array_pull()

  at vendor/flynsarmy/csv-seeder/src/Flynsarmy/CsvSeeder/CsvSeeder.php:168
    164|
    165|                 // skip csv columns that don't exist in the database
    166|                 foreach($mapping  as $index => $fieldname){
    167|                     if (!DB::getSchemaBuilder()->hasColumn($this->table, $fieldname)){
  > 168|                        array_pull($mapping, $index);
    169|                     }
    170|                 }
    171|             }
    172|             else

Resolution

It turns out the array_pull() method was deprecated in Laravel v5.8. These methods are now preferred as static methods: Arr::pull()

The deprecated methods have been separated into a laravel/helpers package. Including this package resolved the issue:

composer require laravel/helpers

You may want to update the library to use the static method, make laravel/helpers a peer dependency, or simply update the README with the requirements. I'd be happy to make a PR if you're interested.

Thanks for the library, by the way. It's very handy!

This PR is actually incredible. Informative and useful. Was it automated?

Would be happy to accept PR.

This should be fixed in release 1.0.7.