You've already forked guangan
1
This commit is contained in:
24
plugs/think-plugs-cms/src/model/CmsArticle.php
Normal file
24
plugs/think-plugs-cms/src/model/CmsArticle.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\cms\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
class CmsArticle extends Model
|
||||
{
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsToMany(CmsCategory::class, CmsCateArticle::class,
|
||||
'cid', 'aid');
|
||||
}
|
||||
|
||||
public function cateids()
|
||||
{
|
||||
return $this->hasMany(CmsCateArticle::class, 'aid');
|
||||
}
|
||||
|
||||
public function getCateIdsAttr()
|
||||
{
|
||||
return $this->cateids->column('cid');
|
||||
}
|
||||
}
|
10
plugs/think-plugs-cms/src/model/CmsBanner.php
Normal file
10
plugs/think-plugs-cms/src/model/CmsBanner.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\cms\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
class CmsBanner extends Model
|
||||
{
|
||||
|
||||
}
|
17
plugs/think-plugs-cms/src/model/CmsCateArticle.php
Normal file
17
plugs/think-plugs-cms/src/model/CmsCateArticle.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\cms\model;
|
||||
|
||||
use think\model\Pivot;
|
||||
|
||||
class CmsCateArticle extends Pivot
|
||||
{
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('CmsCategory', 'cid', 'id');
|
||||
}
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('CmsArtical', 'aid', 'id');
|
||||
}
|
||||
}
|
29
plugs/think-plugs-cms/src/model/CmsCategory.php
Normal file
29
plugs/think-plugs-cms/src/model/CmsCategory.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\cms\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
class CmsCategory extends Model
|
||||
{
|
||||
public static function getList()
|
||||
{
|
||||
return static::mk()->order('sort asc')->field('id,name')->where('status', 1)->select()->toArray();
|
||||
}
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasManyThrough(CmsArticle::class, CmsCateArticle::class,
|
||||
'cid', 'id', 'id', 'aid');
|
||||
}
|
||||
|
||||
public function children()
|
||||
{
|
||||
return $this->hasMany(CmsCategory::class, 'pid', 'id');
|
||||
}
|
||||
|
||||
public function parent()
|
||||
{
|
||||
return $this->belongsTo(CmsCategory::class, 'pid', 'id');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user