Support the ongoing development of Laravel.io →
Eloquent

Hi guys..

i'm using the following code

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use laajchaina\User;

class UsersTableSeeder extends Seeder {

	/**
	 * Run the database seeds.
	 *
	 * @return void
	 */
	public function run()
	{
		$faker = Faker\Factory::create();

		$this->command->info('Clearing Users Table');
		User::truncate();

		$this->command->info('Creating User: zxczxc zxczxc');


		$this->command->info('Creating New Users');
		$users = [];												// initialize new users list
		$users = [													// creating a default admin user
			'firstname' 		=> asdasdasd,
			'lastname'			=> asdasdasd,
			'email' 			=> 'asida@asd.com,
			'password' 			=> Hash::make(asdasdasd),
			'created_at'		=> 'NOW()',
			'updated_at'		=> 'NOW()'
		];

		$counter = 0;
		foreach(range(1, 1000) as $index)							// get a list of random users from Faker lib
		{
			$users[] = [
				'firstname' 	=> $faker->firstname,
				'lastname' 		=> $faker->lastname,
				'email' 		=> $faker->email,
				'password'		=> Hash::make('1234'),
				'created_at'	=> 'NOW()',
				'updated_at'	=> 'NOW()'
			];

			++$counter;
			if( $counter > 100 )
			{
				$counter = 0;
				DB::table('users')->insert($users);
				$users = [];
			}
		}

		DB::table('users')->insert($users);
	}
}

I get the following error while seeding with this seeder:

[ErrorException] preg_replace(): Parameter mismatch, pattern is a string while replacement is an array

can anyone help me with this please.

Last updated 2 years ago.
0

Looks like a missing single quote on line 29 from the formatting!

PHPStorm confirms.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.