CreateFriendsTable::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of Friends.
4
 *
5
 * (c) Christopher Lass <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
use Illuminate\Database\Schema\Blueprint;
12
use Illuminate\Database\Migrations\Migration;
13
use Illuminate\Support\Facades\Config;
14
15
class CreateFriendsTable 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...
16
{
17
    /**
18
     * Run the migrations.
19
     *
20
     * @return void
21
     */
22
    public function up()
0 ignored issues
show
Coding Style introduced by
This method's name is shorter than the configured minimum length of 3 characters.

Even though PHP does not care about the name of your methods, it is generally a good practice to choose method names which can be easily understood by other human readers.

Loading history...
23
    {
24
        Schema::create('friends', function (Blueprint $table) {
25
            $table->unsignedInteger('sender_id')->index();
26
            $table->foreign('sender_id')
27
                ->references('id')
28
                ->on(Config::get('friends.users_table'))
29
                ->onDelete('cascade');
30
            $table->unsignedInteger('recipient_id')->index();
31
            $table->foreign('recipient_id')
32
                ->references('id')
33
                ->on(Config::get('friends.users_table'))
34
                ->onDelete('cascade');
35
            $table->tinyInteger('friendship_status')->default(0);
36
            $table->timestamps();
37
        });
38
    }
39
40
    /**
41
     * Reverse the migrations.
42
     *
43
     * @return void
44
     */
45
    public function down()
46
    {
47
        Schema::dropIfExists('friends');
48
    }
49
}
50