瀏覽代碼

Add like model, migration and controller

Daniel Supernault 7 年之前
父節點
當前提交
5d710d5574
共有 3 個文件被更改,包括 63 次插入0 次删除
  1. 10 0
      app/Http/Controllers/LikeController.php
  2. 18 0
      app/Like.php
  3. 35 0
      database/migrations/2018_04_17_012812_create_likes_table.php

+ 10 - 0
app/Http/Controllers/LikeController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class LikeController extends Controller
+{
+    //
+}

+ 18 - 0
app/Like.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Like extends Model
+{
+    public function actor()
+    {
+      return $this->belongsTo(Profile::class);
+    }
+
+    public function status()
+    {
+      return $this->belongsTo(Status::class);
+    }
+}

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

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateLikesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('likes', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->bigInteger('profile_id')->unsigned();
+            $table->bigInteger('status_id')->unsigned();
+            // Flag to remove spammy profile_ids
+            $table->boolean('flagged')->default(false);
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('likes');
+    }
+}