added seeding all model

master
A1Gard 3 weeks ago
parent 58962bf448
commit f5a2f3dc67

@ -73,6 +73,15 @@ php artisan seeding:image Product digital
``` ```
</div> </div>
یا برای همه مدل‌ها یک‌جا از دستور زیر استفاده کنید:
<div dir="ltr">
```bash
php artisan seeding:all digital
```
</div>
> شما ابتدا باید مدل را نوشته و سپس فولدر مورد نظر برای تصاویر را وارد کنید[bag, clothe, digital, sport, posts, makeup] > شما ابتدا باید مدل را نوشته و سپس فولدر مورد نظر برای تصاویر را وارد کنید[bag, clothe, digital, sport, posts, makeup]
> همچنین می‌توانید یک پوشه درخواه پر از تصاویر jpg دلخواه را در آن پر کنید > همچنین می‌توانید یک پوشه درخواه پر از تصاویر jpg دلخواه را در آن پر کنید

@ -55,9 +55,17 @@ php artisan seeding:prepare
``` ```
- nor copy your image folder to `database/seeders/images/` - nor copy your image folder to `database/seeders/images/`
- then: Seeding image for models: [Group, Category, Post, Product, Slider] - then: Seeding image for models: [Group, Category, Post, Product, Slider]
```bash ```bash
php artisan seeding:image Product digital 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] > 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 > You can create your directory and put your image into new directory then use image seeder

@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SeedImageAll extends Command
{
public $models = ['Category', 'Group', 'Slider', 'Post', 'Product'];
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'seeding:all {directory}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
//
foreach ($this->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);
}
}
}

@ -343,6 +343,7 @@
"Needs Improvement": "نیازمند بهینه‌تر شدن", "Needs Improvement": "نیازمند بهینه‌تر شدن",
"Next": "بعدی", "Next": "بعدی",
"No parent": "بدون والد", "No parent": "بدون والد",
"Not available": "نا موجود",
"Not required": "غیر ضرروری", "Not required": "غیر ضرروری",
"Order removed successfully": "سفارش با موفقیت حذف شد", "Order removed successfully": "سفارش با موفقیت حذف شد",
"Orders": "سفارشاات", "Orders": "سفارشاات",

Loading…
Cancel
Save