From dfbdb1213059ccb84785ecb514c743b532239156 Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Sat, 23 Apr 2022 16:52:47 -0700 Subject: [PATCH] factorio --- database/factories/JoinedFactory.php | 28 +++++++++++++++++++ ...le.php => 01_create_collectives_table.php} | 0 ...php => 20_create_categorizables_table.php} | 2 +- database/seeders/DatabaseSeeder.php | 13 ++++++++- database/seeders/JoinedSeeder.php | 25 +++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 database/factories/JoinedFactory.php rename database/migrations/{01_create_collective_table.php => 01_create_collectives_table.php} (100%) rename database/migrations/{20_create_categorizable_table.php => 20_create_categorizables_table.php} (91%) create mode 100644 database/seeders/JoinedSeeder.php diff --git a/database/factories/JoinedFactory.php b/database/factories/JoinedFactory.php new file mode 100644 index 0000000..2bfa376 --- /dev/null +++ b/database/factories/JoinedFactory.php @@ -0,0 +1,28 @@ + + */ +class JoinedFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'collective_id' => Collective::first(), + 'url' => $this->faker->url(), + 'subject' => $this->faker->word(), + 'image' => $this->faker->imageUrl(), + 'approved' => $this->faker->boolean() + ]; + } +} diff --git a/database/migrations/01_create_collective_table.php b/database/migrations/01_create_collectives_table.php similarity index 100% rename from database/migrations/01_create_collective_table.php rename to database/migrations/01_create_collectives_table.php diff --git a/database/migrations/20_create_categorizable_table.php b/database/migrations/20_create_categorizables_table.php similarity index 91% rename from database/migrations/20_create_categorizable_table.php rename to database/migrations/20_create_categorizables_table.php index a573705..ead2e63 100644 --- a/database/migrations/20_create_categorizable_table.php +++ b/database/migrations/20_create_categorizables_table.php @@ -13,7 +13,7 @@ */ public function up() { - Schema::create('categorizable', function (Blueprint $table) { + Schema::create('categorizables', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->foreignId('category_id') diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 80f3427..bb310b3 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -4,6 +4,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\DB; class DatabaseSeeder extends Seeder { @@ -14,8 +15,18 @@ class DatabaseSeeder extends Seeder */ public function run() { + DB::table('collectives')->insert([ + 'created_at' => now(), + 'updated_at' => now(), + 'name' => 'marley', + 'email' => 'mar@m.punkfairie.net', + 'title' => 'aeipathy', + 'password' => bcrypt('marfan4'), + ]); + $this->call([ - CategorySeeder::class + CategorySeeder::class, + JoinedSeeder::class ]); } } diff --git a/database/seeders/JoinedSeeder.php b/database/seeders/JoinedSeeder.php new file mode 100644 index 0000000..6910507 --- /dev/null +++ b/database/seeders/JoinedSeeder.php @@ -0,0 +1,25 @@ +count(50) + ->hasAttached($cats->random()) + ->create(); + } +}