Skip to content

Commit 88521dc

Browse files
author
ntimobedyeboah
committed
Add database seeder for contacts table
This makes it easier to create contacts without interacting with the application
1 parent 23400b9 commit 88521dc

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

database/factories/ContactFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
$factory->define(Contact::class, function(Faker\Generator $faker) {
1212
return [
13-
'title' => $faker->word,
1413
'first_name' => $faker->firstName,
1514
'last_name' => $faker->lastName,
1615
'email' => $faker->safeEmail,

database/migrations/2017_02_04_220354_create_contacts_table.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public function up()
1515
{
1616
Schema::create('contacts', function (Blueprint $table) {
1717
$table->increments('id');
18-
$table->string('title')->nullable();
1918
$table->string('first_name');
2019
$table->string('last_name');
2120
$table->string('contact_number');
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
use App\Contact;
4+
use Illuminate\Database\Seeder;
5+
6+
class ContactsTableSeeder extends Seeder
7+
{
8+
/**
9+
* Run the database seeds.
10+
*
11+
* @return void
12+
*/
13+
public function run()
14+
{
15+
factory(Contact::class, 20)->create();
16+
}
17+
}

database/seeds/DatabaseSeeder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ class DatabaseSeeder extends Seeder
1212
public function run()
1313
{
1414
// $this->call(UsersTableSeeder::class);
15+
$this->call(ContactsTableSeeder::class);
1516
}
1617
}

0 commit comments

Comments
 (0)