<?php

use App\User;
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // factory('App\User', 10)->create();
        $this->user();
        $this->call(LanguageSeeder::class);
        // $this->call(TranslationSeeder::class);
        $this->call(OptionSeeder::class);
        $this->call(SplitSeeder::class);
        $this->call(TemplateSeeder::class);
        $this->call(PageSeeder::class);
    }

    private function user()
    {
        $name = env('ADMIN_USERNAME', 'username');
        $email = env('ADMIN_EMAIL', 'admin@admin.com');
        $password = env('ADMIN_PASSWORD', 'password');

        $datas = [
            'name' => $name,
            'email' => $email,
            'email_verified_at' => now(),
            'password' => Hash::make($password), // password
            'remember_token' => Str::random(10),
        ];

        User::create($datas);
    }
}
