CreateLaravelLoggerActivityTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
dl 0
loc 44
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 21 2
A down() 0 7 1
1
<?php
2
3
use Illuminate\Database\Migrations\Migration;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Migrations\Migration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
use Illuminate\Database\Schema\Blueprint;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Schema\Blueprint was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Illuminate\Support\Facades\Schema;
6
use jeremykenedy\LaravelLogger\App\Models\Activity;
7
8
class CreateLaravelLoggerActivityTable extends Migration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    /**
11
     * Run the migrations.
12
     *
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        $activity = new Activity();
18
        $connection = $activity->getConnectionName();
19
        $table = $activity->getTableName();
20
        $tableCheck = Schema::connection($connection)->hasTable($table);
21
22
        if (!$tableCheck) {
23
            Schema::connection($connection)->create($table, function (Blueprint $table) {
24
                $table->increments('id');
25
                $table->longText('description');
26
                $table->string('userType');
27
                $table->integer('userId')->nullable();
28
                $table->longText('route')->nullable();
29
                $table->ipAddress('ipAddress')->nullable();
30
                $table->text('userAgent')->nullable();
31
                $table->string('locale')->nullable();
32
                $table->longText('referer')->nullable();
33
                $table->string('methodType')->nullable();
34
                $table->timestamps();
35
                $table->softDeletes();
36
            });
37
        }
38
    }
39
40
    /**
41
     * Reverse the migrations.
42
     *
43
     * @return void
44
     */
45
    public function down()
46
    {
47
        $activity = new Activity();
48
        $connection = $activity->getConnectionName();
49
        $table = $activity->getTableName();
50
51
        Schema::connection($connection)->dropIfExists($table);
52
    }
53
}
54