Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Created database seeders
Browse files Browse the repository at this point in the history
  • Loading branch information
FaZeRs committed Apr 9, 2019
1 parent fca205e commit fc3a2a6
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion database/factories/CategoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
*/
$factory->define(App\Models\Category::class, function (Faker $faker) {
return [
'title' => $faker->sentence,
'title' => $faker->sentence(2),
];
});
2 changes: 1 addition & 1 deletion database/factories/LinkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
return factory(App\Models\Project::class)->create()->id;
},
'url' => $faker->url,
'icon' => $faker->word,
'icon' => $faker->randomElement(['open_in_browser', 'mdi-github-circle', 'mdi-gitlab', 'mdi-bitbucket']),
];
});
2 changes: 1 addition & 1 deletion database/factories/ProjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
return factory(App\Models\Category::class)->create()->id;
},
'description' => $faker->paragraph,
'image' => 'projects/' . $faker->image(storage_path('app/public/projects'), 640, 480, null, false),
'visible' => $faker->boolean($chanceOfGettingTrue = 80),
'order' => $faker->randomDigit,
'status' => $faker->randomElement([
Expand All @@ -29,6 +30,5 @@
'completed',
'cancelled',
]),
'image' => $faker->imageUrl($width = 640, $height = 480),
];
});
2 changes: 1 addition & 1 deletion database/factories/TagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
$factory->define(App\Models\Tag::class, function (Faker $faker) {
return [
'title' => $faker->sentence,
'title' => $faker->word,
'color' => $faker->colorName,
];
});
16 changes: 16 additions & 0 deletions database/seeds/CategoriesTableSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Illuminate\Database\Seeder;

class CategoriesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Category::class, 3)->create();
}
}
6 changes: 5 additions & 1 deletion database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
// $this->call(UsersTableSeeder::class);
$this->call([
CategoriesTableSeeder::class,
TagsTableSeeder::class,
ProjectsTableSeeder::class,
]);
}
}
23 changes: 23 additions & 0 deletions database/seeds/ProjectsTableSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use Illuminate\Database\Seeder;

class ProjectsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Project::class, 6)->create([
'category_id' => App\Models\Category::inRandomOrder()->first()->id
])->each(function ($project) {
$project->tags()->saveMany(App\Models\Tag::inRandomOrder()->take(3)->get());
$project->links()->saveMany(factory(App\Models\Link::class, 2)->make([
'project_id' => $project->id,
]));
});
}
}
16 changes: 16 additions & 0 deletions database/seeds/TagsTableSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Illuminate\Database\Seeder;

class TagsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\Models\Tag::class, 6)->create();
}
}

0 comments on commit fc3a2a6

Please sign in to comment.