12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2020-09-18
- * Time: 11:30
- */
-
- namespace api\js\model;
-
-
- use think\Model;
- class PortalPostModel extends Model
- {
-
- protected $type = [
- 'more' => 'array',
- ];
-
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = true;
-
- /**
- * 关联 user表
- * @return \think\model\relation\BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('UserModel', 'user_id')->setEagerlyType(1);
- }
-
- /**
- * 关联分类表
- * @return \think\model\relation\BelongsToMany
- */
- public function categories()
- {
- return $this->belongsToMany('PortalCategoryModel', 'portal_category_post', 'category_id', 'post_id');
- }
-
- /**
- * 关联标签表
- * @return \think\model\relation\BelongsToMany
- */
- public function tags()
- {
- return $this->belongsToMany('PortalTagModel', 'portal_tag_post', 'tag_id', 'post_id');
- }
-
- /**
- * post_content 自动转化
- * @param $value
- * @return string
- */
- public function getPostContentAttr($value)
- {
- return cmf_replace_content_file_url(htmlspecialchars_decode($value));
- }
-
- }
|