Skip to content

Commit 4796a31

Browse files
committed
changes in migration and factory
1 parent fdd23a1 commit 4796a31

4 files changed

+17
-10
lines changed

database/factories/CategoryFactory.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
use Faker\Generator as Faker;
77

88
$factory->define(Category::class, function (Faker $faker) {
9+
$name = $faker->sentence();
10+
$slug = str_slug($name);
11+
912
return [
10-
//
13+
'name' => $name,
14+
'slug' => $slug,
15+
'description' => $faker->text
1116
];
1217
});

database/migrations/2014_10_12_000000_create_users_table.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public function up()
1919
$table->string('email')->unique();
2020
$table->timestamp('email_verified_at')->nullable();
2121
$table->string('password');
22-
$table->string('image');
23-
$table->integer('post_id');
24-
$table->integer('category_id');
25-
$table->string('bio');
26-
$table->string('website');
27-
$table->string('github');
22+
$table->string('image')->nullable();
23+
$table->integer('post_id')->nullable();
24+
$table->integer('category_id')->nullable();
25+
$table->string('bio')->nullable();
26+
$table->string('website')->nullable();
27+
$table->string('github')->nullable();
2828
$table->rememberToken();
2929
$table->timestamps();
3030
});

database/migrations/2019_12_20_051604_create_categories_table.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public function up()
1717
$table->bigIncrements('id');
1818
$table->string('name');
1919
$table->string('slug');
20-
$table->string('description');
21-
$table->integer('user_id');
22-
$table->integer('post_id');
20+
$table->text('description');
21+
$table->integer('user_id')->nullable();
22+
$table->integer('post_id')->nullable();
2323
$table->timestamps();
2424
});
2525
}

database/seeds/DatabaseSeeder.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Database\Seeder;
44
use App\post;
5+
use App\Category;
56

67
class DatabaseSeeder extends Seeder
78
{
@@ -14,5 +15,6 @@ public function run()
1415
{
1516
// $this->call(UsersTableSeeder::class);
1617
factory(Post::class, 100)->create();
18+
factory(Category::class, 50)->create();
1719
}
1820
}

0 commit comments

Comments
 (0)