From 9d95a48ed71f7542ed357d9c42c3e6beef0c5deb Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Sat, 20 May 2023 20:41:59 +0300 Subject: [PATCH] use config model in seeders --- database/seeders/SkySeeder.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/database/seeders/SkySeeder.php b/database/seeders/SkySeeder.php index 794eb8e..254f467 100644 --- a/database/seeders/SkySeeder.php +++ b/database/seeders/SkySeeder.php @@ -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 { @@ -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'); } @@ -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'); + } } }