浏览代码

Add FollowRequest model/migration

Daniel Supernault 6 年之前
父节点
当前提交
f9fc8e2f64
共有 2 个文件被更改,包括 53 次插入0 次删除
  1. 18 0
      app/FollowRequest.php
  2. 35 0
      database/migrations/2018_09_02_042235_create_follow_requests_table.php

+ 18 - 0
app/FollowRequest.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class FollowRequest extends Model
+{
+    public function follower()
+    {
+        return $this->belongsTo(Profile::class, 'follower_id', 'id');
+    }
+
+    public function following()
+    {
+        return $this->belongsTo(Profile::class, 'following_id', 'id');
+    }
+}

+ 35 - 0
database/migrations/2018_09_02_042235_create_follow_requests_table.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateFollowRequestsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('follow_requests', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->bigInteger('follower_id')->unsigned()->index();
+            $table->bigInteger('following_id')->unsigned()->index();
+            $table->boolean('is_rejected')->default(false);
+            $table->boolean('is_local')->default(false);
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('follow_requests');
+    }
+}