PHP code example of jeroenzwart / laravel-csv-seeder
1. Go to this page and download the library: Download jeroenzwart/laravel-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/ */
jeroenzwart / laravel-csv-seeder example snippets
use JeroenZwart\CsvSeeder\CsvSeeder;
class UsersTableSeeder extends CsvSeeder
{
public function __construct()
{
$this->file = '/database/seeds/csvs/users.csv';
}
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Recommended when importing larger CSVs
DB::disableQueryLog();
parent::run();
}
}
public function __construct()
{
$this->file = '/database/seeds/csvs/users.csv';
$this->tablename = 'email_users';
$this->timestamps = '1970-01-01 00:00:00';
}
public function __construct()
{
$this->file = '/database/seeds/csvs/other_users.csv';
$this->connection = 'second_db';
$this->tablename = 'second_users';
}
public function __construct()
{
$this->file = '/database/seeds/csvs/users.csv';
$this->mapping = ['id', 'firstname', 'lastname'];
$this->header = FALSE;
}