1. Go to this page and download the library: Download flynsarmy/csv-seeder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flynsarmy / csv-seeder example snippets
use Flynsarmy\CsvSeeder\CsvSeeder;
class StopsTableSeeder extends CsvSeeder {
public function __construct()
{
$this->table = 'your_table';
$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
}
public function run()
{
// Recommended when importing larger CSVs
DB::disableQueryLog();
// Uncomment the below to wipe the table clean before populating
DB::table($this->table)->truncate();
parent::run();
}
}
public function __construct()
{
$this->table = 'users';
$this->csv_delimiter = '|';
$this->filename = base_path().'/database/seeds/csvs/your_csv.csv';
}