Przeglądaj źródła

add content_type

visuddhinanda 3 lat temu
rodzic
commit
7cbdf4dfba

+ 1 - 0
app/Http/Controllers/DiscussionController.php

@@ -92,6 +92,7 @@ class DiscussionController extends Controller
         $discussion->res_type = $request->get('res_type');
         $discussion->title = $request->get('title',null);
         $discussion->content = $request->get('content',null);
+        $discussion->content_type = $request->get('content_type',"markdown");
         $discussion->parent = $request->get('parent',null);
         $discussion->editor_uid = $user['user_uid'];
         $discussion->save();

+ 1 - 0
app/Http/Resources/DiscussionResource.php

@@ -19,6 +19,7 @@ class DiscussionResource extends JsonResource
             "id"=>$this->id,
             "title"=> $this->title,
             "content"=> $this->content,
+            "content_type"=> $this->content_type,
             "parent"=> $this->parent,
             "children_count"=> $this->children_count,
             "editor"=> StudioApi::getById($this->editor_uid),

+ 34 - 0
database/migrations/2023_02_25_124246_add_content_type_in_discussions.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddContentTypeInDiscussions extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('discussions', function (Blueprint $table) {
+            //
+            $table->enum('content_type',['markdown','text','html'])->default('markdown');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('discussions', function (Blueprint $table) {
+            //
+            $table->dropColumn('content_type');
+        });
+    }
+}