|
@@ -7,11 +7,14 @@ use think\facade\Config;
|
|
use think\facade\Db;
|
|
use think\facade\Db;
|
|
|
|
|
|
use app\common\model\Base;
|
|
use app\common\model\Base;
|
|
|
|
+use app\common\model\Article;
|
|
|
|
|
|
class TagArticle extends Base
|
|
class TagArticle extends Base
|
|
{
|
|
{
|
|
|
|
+ protected $pk = 'atid';
|
|
|
|
+
|
|
protected $schema = [
|
|
protected $schema = [
|
|
- 'id' => "int",
|
|
|
|
|
|
+ 'atid' => "int",
|
|
"infoid" => "int",
|
|
"infoid" => "int",
|
|
"cid" => "int",
|
|
"cid" => "int",
|
|
"tagid" => "int",
|
|
"tagid" => "int",
|
|
@@ -21,17 +24,17 @@ class TagArticle extends Base
|
|
|
|
|
|
public function article()
|
|
public function article()
|
|
{
|
|
{
|
|
- return $this->belongsTo('Article', 'infoid', 'id')->bind(['id','cid','title','titlepic','summary','hits','create_time','username']);
|
|
|
|
|
|
+ return $this->belongsTo('Article', 'infoid')->bind(['id','title','titlepic','summary','hits','create_time','username']);
|
|
}
|
|
}
|
|
|
|
|
|
public function category()
|
|
public function category()
|
|
{
|
|
{
|
|
- return $this->belongsTo('Category', 'cid', 'id')->bind(['category_url'=>'url','category_name'=>'name']);
|
|
|
|
|
|
+ return $this->belongsTo('Category', 'cid')->bind(['category_url'=>'url','category_name'=>'name']);
|
|
}
|
|
}
|
|
|
|
|
|
public static function queryList($tagid)
|
|
public static function queryList($tagid)
|
|
{
|
|
{
|
|
- $limit = Config::get('app.page_size', 20);
|
|
|
|
|
|
+ $limit = (int) Config::get('app.page_size', 20);
|
|
|
|
|
|
return self::with(['article','category'])->where('tagid', $tagid)->limit($limit)->paginate();
|
|
return self::with(['article','category'])->where('tagid', $tagid)->limit($limit)->paginate();
|
|
}
|
|
}
|