Completed
Push — master ( 423a77...7e6e45 )
by Christopher
13:19
created

CreateFriendsTable::up()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 14
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
use Illuminate\Database\Schema\Blueprint;
11
use Illuminate\Database\Migrations\Migration;
12
13
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...
14
{
15
    /**
16
     * Run the migrations.
17
     *
18
     * @return void
19
     */
20
    public function up()
21
    {
22
        Schema::create('friends', function (Blueprint $table) {
23
            $table->unsignedInteger('sender_id')->index();
24
            $table->foreign('sender_id')
25
                ->references('id')
26
                ->on(\Config::get('friends.users_table'))
27
                ->onDelete('cascade');
28
            $table->unsignedInteger('recipient_id')->index();
29
            $table->foreign('recipient_id')
30
                ->references('id')
31
                ->on(\Config::get('friends.users_table'))
32
                ->onDelete('cascade');
33
            $table->tinyInteger('status')->default(0);
34
            $table->timestamps();
35
        });
36
    }
37
38
    /**
39
     * Reverse the migrations.
40
     *
41
     * @return void
42
     */
43
    public function down()
44
    {
45
        Schema::dropIfExists('friends');
46
    }
47
}
48