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
|
|||
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 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.