<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Model\Points;

class CreateTableMasterPoints extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('master_points', function (Blueprint $table) {
            $table->id();
            $table->string('type');
            $table->integer('value')->unsigned();
            $table->timestamps();
        });

        $dump = [
            'check_vehicle' => 10,
            'safety_riding' => 10,
            'read_news' => 10,
            'invitation' => 10,
            'timeline' => 10,
            'trivia' => 10,
            'take_call' => 10,
            'speeding' => 10,
            'sudden_brake' => 10,
            'bonus_poin' => 10
        ];

        foreach ($dump as $key => $value) {
            $point = new Points();
            $point->type = $key;
            $point->value = $value;
            $point->save();
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('master_points');
    }
}
