Content.php 760 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class Content extends Model
  6. {
  7. protected $table = 'content';
  8. protected $primaryKey = 'content_id';
  9. protected $dateFormat = 'U';
  10. const CREATED_AT = 'content_addtimes';
  11. const UPDATED_AT = 'content_updatetimes';
  12. protected function serializeDate(DateTimeInterface $date)
  13. {
  14. return $date->format('Y-m-d H:i:s');
  15. }
  16. public function category(){
  17. return $this->hasOne(SysCategory::class,'category_id','join_content_category_id')
  18. ->select('category_id','category_name');
  19. }
  20. public function user(){
  21. return $this->hasOne(SysUser::class,'user_id','creator_user_id')
  22. ->select('user_id','user_name');
  23. }
  24. }