1#All of them
2php artisan db:seed
3#One class
4php artisan db:seed --class=UserSeeder
1<?php
2
3use Illuminate\Database\Seeder;
4use Illuminate\Support\Facades\DB;
5use Illuminate\Support\Facades\Hash;
6use Illuminate\Support\Str;
7
8class DatabaseSeeder extends Seeder
9{
10 /**
11 * Run the database seeds.
12 *
13 * @return void
14 */
15 public function run()
16 {
17 DB::table('users')->insert([
18 'name' => Str::random(10),
19 'email' => Str::random(10).'@gmail.com',
20 'password' => Hash::make('password'),
21 ]);
22 }
23}
1<?php
2 //Test laravel 7.3
3use App\Models\Eloquent\DriversModel;
4use Illuminate\Database\Seeder;
5
6class DriversSeeder extends Seeder
7{
8 /**
9 * Run the database seeds.
10 *
11 * @return void
12 */
13 public function run()
14 {
15 if (Schema::hasTable("drivers")) {
16 // Nechta generatsiya qilish kerak bo`lsa belgilanadi default 10 tani tashkil qiladi
17 $count = (int)$this->command->ask('Necha dona Ustun qo`shishim kerak?', 10);
18 for ($i=1; $i < $count; $i++) {
19 DriversModel::query()->updateOrCreate(['id' => $i], [
20 'car_number' => ''.$i.'A365EA',
21 'trailer_number' => 'a5s6d4321c2a6',
22 'technical_passport' => 'asd56a5sa6f5',
23 'full_name' => 'Akbarali'.$i.'',
24 'passport' => '{"0": "test'.$i.'.png", "1": "test1'.$i.'.png"}',
25 'license_limitation' => '6567965',
26 'license' => '{"0": "test'.$i.'.png", "1": "test1'.$i.'.png"}',
27 'rate' => '54546'.$i,
28 'user_id' => '3',
29 ]);
30 $this->command->info("{$i} ustun qo'shildi.");
31 }
32 $this->command->info("Jami {$i} ustun qo'shildi.");
33 }
34 }
35}
36