This commit is contained in:
Marley Rae 2022-04-23 16:52:47 -07:00
parent 3f9376addb
commit dfbdb12130
5 changed files with 66 additions and 2 deletions

View file

@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Models\Collective;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Joined>
*/
class JoinedFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'collective_id' => Collective::first(),
'url' => $this->faker->url(),
'subject' => $this->faker->word(),
'image' => $this->faker->imageUrl(),
'approved' => $this->faker->boolean()
];
}
}

View file

@ -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')

View file

@ -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
]);
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace Database\Seeders;
use App\Models\Category;
use App\Models\Joined;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class JoinedSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$cats = Category::all();
Joined::factory()
->count(50)
->hasAttached($cats->random())
->create();
}
}