From f5a2f3dc67ffe362e81d4afad506a05c87d32784 Mon Sep 17 00:00:00 2001 From: A1Gard Date: Mon, 4 Nov 2024 15:46:50 +0330 Subject: [PATCH] added seeding all model --- README-fa.md | 9 +++++ README.md | 8 +++++ app/Console/Commands/SeedImageAll.php | 48 +++++++++++++++++++++++++++ resources/lang/fa.json | 1 + 4 files changed, 66 insertions(+) create mode 100644 app/Console/Commands/SeedImageAll.php diff --git a/README-fa.md b/README-fa.md index f15a46a..f709b44 100644 --- a/README-fa.md +++ b/README-fa.md @@ -73,6 +73,15 @@ php artisan seeding:image Product digital ``` +یا برای همه مدل‌ها یک‌جا از دستور زیر استفاده کنید: + +
+ +```bash +php artisan seeding:all digital +``` +
+ > شما ابتدا باید مدل را نوشته و سپس فولدر مورد نظر برای تصاویر را وارد کنید[bag, clothe, digital, sport, posts, makeup] > همچنین می‌توانید یک پوشه درخواه پر از تصاویر jpg دلخواه را در آن پر کنید diff --git a/README.md b/README.md index 86dfa5c..3824b9a 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,17 @@ php artisan seeding:prepare ``` - nor copy your image folder to `database/seeders/images/` - then: Seeding image for models: [Group, Category, Post, Product, Slider] + ```bash php artisan seeding:image Product digital ``` + +Or to seed all models: + +```bash +php artisan seeding:all digital +``` + > First parameter is Model, Second is image seeder directory available [bag, clothe, digital, sport, posts, makeup] > You can create your directory and put your image into new directory then use image seeder diff --git a/app/Console/Commands/SeedImageAll.php b/app/Console/Commands/SeedImageAll.php new file mode 100644 index 0000000..2cfe38a --- /dev/null +++ b/app/Console/Commands/SeedImageAll.php @@ -0,0 +1,48 @@ +models as $model) { + // Call the seeder command + $exitCode = \Artisan::call('seeding:image', ['directory' => $this->argument('directory'), 'model' => $model]); + + // Get the output + $output = \Artisan::output(); + + // Handle the exit code and output as needed + if ($exitCode === 0) { + $this->info( "Seeding was successful: [$model] \n"); + } else { + $this->error("Seeding failed with exit code {$exitCode}:\n"); + } + $this->info( $output); + } + } +} diff --git a/resources/lang/fa.json b/resources/lang/fa.json index eb0abe7..eb48ef7 100644 --- a/resources/lang/fa.json +++ b/resources/lang/fa.json @@ -343,6 +343,7 @@ "Needs Improvement": "نیازمند بهینه‌تر شدن", "Next": "بعدی", "No parent": "بدون والد", + "Not available": "نا موجود", "Not required": "غیر ضرروری", "Order removed successfully": "سفارش با موفقیت حذف شد", "Orders": "سفارشاات",