xielin лет назад: 6
Родитель
Сommit
cd1f7b181b
2 измененных файлов с 52 добавлено и 0 удалено
  1. 26 0
      app/Http/Models/CmsSubject.php
  2. 26 0
      app/Http/Models/CmsSubjectProduct.php

+ 26 - 0
app/Http/Models/CmsSubject.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Models;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class CmsSubject extends BaseModel
+{
+    use SoftDeletes;
+
+    protected $dates = ['deleted_at'];
+    protected  $table = 'cms_subject';
+
+
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['city_id','city_name','title','show_type','is_open'];
+
+    //一对多关联专题商品表
+    public function cmsSubjectProduct()
+    {
+        return $this->hasMany('App\Models\CmsSubjectProduct','subject_id');
+    }
+
+}

+ 26 - 0
app/Http/Models/CmsSubjectProduct.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace App\Models;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class CmsSubjectProduct extends BaseModel
+{
+    use SoftDeletes;
+
+    protected $dates = ['deleted_at'];
+    protected  $table = 'cms_subject_product';
+
+
+    /**
+     * 可被批量赋值的字段
+     * @var array
+     */
+    protected $fillable = ['product_id','sort','subject_id'];
+
+    //相对关联到专题表
+    public function cmsSubject()
+    {
+        return $this->belongsTo('App\Models\CmsSubject','subject_id');
+    }
+
+}