use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { Model::unguard();
$this->call(ContactsTableSeeder::class);
$this->call(UserTableSeeder::class);
$this->call(EventsTableSeeder::class);
Model::reguard();
}
}
//below is the contacts seeder file. It is already located in the same folder as the dbseeder. I already tried composer dump-autoload
use Illuminate\Database\Seeder; use App\contacts;
class ContactsTable extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { //create faker data for tables $faker = Faker\Factory::create();
for($i = 0; $i <= 10; $i++)
{
//creating the object
$contact = new Contact();
//populating data in the column names
$contact->$faker->firstName;
$contact->$faker->lastName;
$contact->$faker->middleName;
$contact->$faker->email;
$contact->$faker->phoneNumber;
//saving the entry/contact info
$contact->save();
}
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire