<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Models\DeviceModelNumber;
use Illuminate\Support\Str;

class ModelNumberSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $device_type_ids = DB::table('device_type')->pluck('tid')->toArray();

        $faker = app(Faker\Generator::class);
        $modelNumbers = factory(DeviceModelNumber::class)
            ->times(20)
            ->make()
            ->each(function ($modelNumber, $index) use($device_type_ids, $faker){
                $modelNumber->device_type_id = $faker->randomElement($device_type_ids);
            });
        DeviceModelNumber::insert($modelNumbers->toArray());
    }
}
