소스 검색

add fillable attributes

visuddhinanda 1 년 전
부모
커밋
a045433af3
1개의 변경된 파일22개의 추가작업 그리고 3개의 파일을 삭제
  1. 22 3
      api-v8/app/Models/Discussion.php

+ 22 - 3
api-v8/app/Models/Discussion.php

@@ -9,7 +9,26 @@ class Discussion extends Model
 {
     use HasFactory;
     protected $primaryKey = 'id';
-	protected $casts = [
-		'id' => 'string'
-	];
+    protected $casts = [
+        'id' => 'string'
+    ];
+
+    //批量填充
+    protected $fillable = [
+        'res_id',
+        'res_type',
+        'type',
+        'tpl_id',
+        'title',
+        'content',
+        'content_type',
+        'parent',
+        'editor_uid',
+    ];
+
+    // 设置默认值
+    protected $attributes = [
+        'content_type' => 'markdown',
+        'type' => 'discussion'
+    ];
 }