CreateVisitorsTable::up()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 25
rs 9.568
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * CreateVisitorsTable.php
5
 *
6
 * This migration creates the visitors table.
7
 *
8
 * PHP version 7.2
9
 *
10
 * @category Migrations
11
 * @package  RedboxTracker
12
 * @author   Johnny Mast <[email protected]>
13
 * @license  https://opensource.org/licenses/MIT MIT
14
 * @link     https://github.com/johnnymast/redbox-tracker
15
 * @since    GIT:1.0
16
 */
17
18
use Illuminate\Database\Migrations\Migration;
19
use Illuminate\Database\Schema\Blueprint;
20
use Illuminate\Support\Facades\Schema;
21
22
/**
23
 * Class CreateVisitorsTable
24
 *
25
 * @category Migrations
26
 * @package  RedboxTracker
27
 * @author   Johnny Mast <[email protected]>
28
 * @license  https://opensource.org/licenses/MIT MIT
29
 * @link     https://github.com/johnnymast/redbox-tracker
30
 * @since    GIT:1.0
31
 */
32
class CreateVisitorsTable extends Migration
33
{
34
    /**
35
     * Run the migrations.
36
     *
37
     * @return void
38
     */
39
    public function up(): void
40
    {
41
        Schema::create(
42
            'visitors', function (Blueprint $table) {
43
44
                $table->increments('id');
45
                $table->string('unique_id');
46
                $table->unsignedInteger('user_id')->nullable();
47
                $table->string('ip', 40);
48
                $table->string('user_agent')->nullable();
49
                $table->boolean('is_desktop')->default(false);
50
                $table->boolean('is_mobile')->default(false);
51
                $table->boolean('is_bot')->default(false);
52
                $table->string('bot')->nullable();
53
                $table->string('os')->default('');
54
                $table->string('browser_version')->default('');
55
                $table->string('browser')->default('');
56
                $table->string('country')->default('');
57
                $table->string('country_code')->default('');
58
                $table->string('city')->default('');
59
                $table->double('lat')->nullable();
60
                $table->double('long')->nullable();
61
                $table->string('browser_language_family', 4)->default('');
62
                $table->string('browser_language', 7)->default('');
63
                $table->timestamps();
64
            }
65
        );
66
    }
67
68
    /**
69
     * Reverse the migrations.
70
     *
71
     * @return void
72
     */
73
    public function down(): void
74
    {
75
        Schema::dropIfExists('visitors');
76
    }
77
}
78