<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class Recaptcha extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $setting = new \App\Models\Setting();
        $setting->name = "recaptcha_v2_register";
        $setting->description = "Enabled Recaptcha for Register Page";
        $setting->typ = "checkbox";
        $setting->value = 0;
        $setting->saveOrFail();
        $setting = new \App\Models\Setting();
        $setting->name = "recaptcha_v2_login";
        $setting->description = "Enabled Recaptcha for Login to Account-Service";
        $setting->typ = "checkbox";
        $setting->value = 0;
        $setting->saveOrFail();
        $setting = new \App\Models\Setting();
        $setting->name = "recaptcha_v2_key";
        $setting->description = "Recaptcha V2 Key";
        $setting->typ = "textinput";
        $setting->value = "";
        $setting->saveOrFail();
        $setting = new \App\Models\Setting();
        $setting->name = "recaptcha_v2_secret";
        $setting->description = "Recaptcha V2 Secret";
        $setting->typ = "textinput";
        $setting->value = "";
        $setting->saveOrFail();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        \App\Models\Setting::query()->where("name", "=", "recaptcha_v2_register")->delete();
        \App\Models\Setting::query()->where("name", "=", "recaptcha_v2_login")->delete();
        \App\Models\Setting::query()->where("name", "=", "recaptcha_v2_key")->delete();
        \App\Models\Setting::query()->where("name", "=", "recaptcha_v2_secret")->delete();
    }
}