Click here to Skip to main content
15,847,077 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have a table with ENUM field like below

Role ENUM('Admin','User')

I want to create seed file to insert value to the table but its giving me the error "Array to String Conversion".

Please help.

What I have tried:

class UsersSeeder extends Seeder
    public function run()
            $data = [
                ['username' => 'admin',
                'passwd'    => '1234',
                'role'      => 1
                    'username' => 'user',
                    'passwordd'    => '1234',
                    'role'      => 2

Updated 9-Dec-22 5:30am

1 solution

Share this answer
nyt1972 9-Dec-22 10:05am    
InsertBatch works fine but when I add the Enum field role then it gives the error.
nyt1972 9-Dec-22 10:29am    
Thanks Richard MacCutchan for reply, separate insert queries worked fine for me instead of insertBatch.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900