Test Failed
Push — master ( b7cafb...0e3ff1 )
by Carlos
03:33
created

migrations/create_laravel_follow_tables.php (1 issue)

1
<?php
2
3
/*
4
 * This file is part of the overtrue/laravel-follow
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
use Illuminate\Database\Schema\Blueprint;
13
use Illuminate\Database\Migrations\Migration;
14
15
class CreateLaravelFollowTables 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
    public function up()
21
    {
22
        Schema::create(config('follow.followable_table', 'followables'), function (Blueprint $table) {
23
            $table->unsignedInteger('user_id');
24
            $table->unsignedInteger('followable_id');
25
            $table->string('followable_type')->index();
26
            $table->string('relation')->default('follow')->comment('folllow/like/subscribe/favorite/');
27
            $table->timestamp('created_at');
28
29
            $table->foreign('user_id')
30
                ->references(config('follow.users_table_primary_key', 'id'))
31
                ->on(config('follow.users_table_name', 'users'))
32
                ->onUpdate('cascade')
33
                ->onDelete('cascade');
34
        });
35
    }
36
37
    /**
38
     * Reverse the migrations.
39
     */
40
    public function down()
41
    {
42
        Schema::table(config('follow.followable_table', 'followables'), function ($table) {
43
            $table->dropForeign(config('follow.followable_table', 'followables').'_user_id_foreign');
44
        });
45
46
        Schema::drop(config('follow.followable_table', 'followables'));
47
    }
48
}
49