Skip to content

Commit

Permalink
use config model in seeders
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed May 20, 2023
1 parent 8c1d1a8 commit 9d95a48
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion database/seeders/SkySeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Database\Seeders;

use Illuminate\Database\Seeder;
use LaraZeus\Sky\Models\Library;
use LaraZeus\Sky\Models\Tag;

class SkySeeder extends Seeder
{
Expand All @@ -16,7 +18,7 @@ public function run()
->count(8)
->create();

foreach (config('zeus-sky.models.post')::all() as $post) { // loop through all posts
foreach (config('zeus-sky.models.post')::all() as $post) {
$random_tags = config('zeus-sky.models.tag')::all()->random(1)->first()->name;
$post->syncTagsWithType([$random_tags], 'category');
}
Expand All @@ -27,5 +29,10 @@ public function run()
config('zeus-sky.models.library')::factory()
->count(8)
->create();

foreach (config('zeus-sky.models.library')::all() as $library) {
$random_tags = config('zeus-sky.models.tag')::getWithType('library')->random(1)->first()->name;
$library->syncTagsWithType([$random_tags], 'library');
}
}
}

0 comments on commit 9d95a48

Please sign in to comment.