Reputation: 25
I want to use php artisan db:seed command on my cmd but it said Label 'DB' already defined,
this is my SeederTableAnggota Code:
<?php
use Illuminate\Database\Seeder;
class SeederTableAnggota extends Seeder {
Public function run()
{
DB:table('anggota')->delete();
$anggota= array(
array('id'=>1,'nama'=>'Rizki Amelia Dewi','alamat'=>'Cilengsi'),
array('id'=>2,'nama'=>'Dewi Ayunindita','alamat'=>'Jatinangor'),
array('id'=>3,'nama'=>'Siti Hajar Riska','alamat'=>'Jakarta')
);
DB:table('anggota')->insert('anggota');
}
}
i already use $this->call('SeederTableAnggota') on my DatabaseSeeder.php.
And i already use composer dump-autoload on my cmd too.
So how can i use db:seed and why it said Label 'DB' already defined? thanks for your help and any help will be very useful
Upvotes: 2
Views: 1799
Reputation: 1
just completing your answer, in my case the problem was because I was typing db::seed when the correct one is db:seed ie I was putting :: when the correct one is : , silly mistake but when you are tired goes unnoticed.
Upvotes: 0
Reputation: 885
It's because you have written DB:table(...)
instead of DB::table(...)
.
You forgot a colon so PHP thought that it is a constant.
Your seeder seems to be too complicated. Do you have a model?
Upvotes: 5