You've already forked guangan
点赞的接口
This commit is contained in:
@ -6,5 +6,19 @@ use think\admin\Model;
|
||||
|
||||
class CmsThumb extends Model
|
||||
{
|
||||
protected $append = ['imgs_arr'];
|
||||
public function like()
|
||||
{
|
||||
return $this->hasMany(CmsThumbLike::class, 'thumb_id', 'id');
|
||||
}
|
||||
|
||||
public function scopePublished($query)
|
||||
{
|
||||
$query->where(['status' => 1])->where('publish_at', '<=', date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
public function getImgsArrAttr($value, $data)
|
||||
{
|
||||
return str2arr($data['images']);
|
||||
}
|
||||
}
|
13
plugs/think-plugs-cms/src/model/CmsThumbLike.php
Normal file
13
plugs/think-plugs-cms/src/model/CmsThumbLike.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\cms\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
class CmsThumbLike extends Model
|
||||
{
|
||||
public function thumb()
|
||||
{
|
||||
return $this->belongsTo(CmsThumb::class, 'thumb_id');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user