<?php

namespace Database\Seeders;

use App\Models\Company;
use App\Models\Lang;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class CompanyTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */

    public function run()
    {
        Model::unguard();

        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
        DB::table('companies')->delete();
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');

        DB::statement('ALTER TABLE companies AUTO_INCREMENT = 1');

        $faker = \Faker\Factory::create();

        $enLang = Lang::where('key', 'en')->first();

        $adminCompany = new Company();
        $adminCompany->name = 'Webifly AI';
        $adminCompany->short_name = 'Webifly';
        $adminCompany->email = 'company@example.com';
        $adminCompany->phone = $faker->e164PhoneNumber();
        $adminCompany->address = '7 street, city, state, 762782';
        $adminCompany->lang_id = $enLang->id;
        $adminCompany->save();
    }
}
