update cms
This commit is contained in:
parent
44f5bf345b
commit
72bf97579b
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CatchAdmin [Just Like ~ ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: JaguarJack [ njphper@gmail.com ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
use think\migration\Migrator;
|
||||||
|
use think\migration\db\Column;
|
||||||
|
|
||||||
|
class UpdateArticleColumns extends Migrator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* Write your reversible migrations using this method.
|
||||||
|
*
|
||||||
|
* More information on writing migrations is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
|
||||||
|
*
|
||||||
|
* The following commands can be used in this method and Phinx will
|
||||||
|
* automatically reverse them when rolling back:
|
||||||
|
*
|
||||||
|
* createTable
|
||||||
|
* renameTable
|
||||||
|
* addColumn
|
||||||
|
* renameColumn
|
||||||
|
* addIndex
|
||||||
|
* addForeignKey
|
||||||
|
*
|
||||||
|
* Remember to call "create()" or "update()" and NOT "save()" when working
|
||||||
|
* with the Table class.
|
||||||
|
*/
|
||||||
|
public function change()
|
||||||
|
{
|
||||||
|
if ($this->hasTable('cms_articles')) {
|
||||||
|
$table = $this->table('cms_articles');
|
||||||
|
|
||||||
|
$table->renameColumn('comments', 'comment_num')
|
||||||
|
->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -75,7 +75,7 @@ class Articles extends BaseModel
|
|||||||
// 喜欢
|
// 喜欢
|
||||||
'likes',
|
'likes',
|
||||||
// 评论数
|
// 评论数
|
||||||
'comments',
|
'comment_num',
|
||||||
// 1 置顶 2 非置顶
|
// 1 置顶 2 非置顶
|
||||||
'is_top',
|
'is_top',
|
||||||
// 1 推荐 2 不推荐
|
// 1 推荐 2 不推荐
|
||||||
@ -182,4 +182,15 @@ class Articles extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->tag()->attach($ids);
|
return $this->tag()->attach($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章评论
|
||||||
|
*
|
||||||
|
* @time 2021年05月27日
|
||||||
|
* @return \think\model\relation\HasMany
|
||||||
|
*/
|
||||||
|
public function comments(): \think\model\relation\HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Comments::class, 'article_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user