Bill.php 585 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * 收藏模型
  4. */
  5. namespace app\model;
  6. use laytp\BaseModel;
  7. class Bill extends BaseModel
  8. {
  9. //模型名
  10. protected $name = 'bill';
  11. //附加属性
  12. protected $append = ['create_time_int'];
  13. //时间戳字段转换
  14. //关联模型
  15. public function userinfo(){
  16. return $this->belongsTo('app\model\User','uid','id')->bind(['nickname']);
  17. }
  18. //新增属性的方法
  19. public function getCreateTimeIntAttr($value, $data)
  20. {
  21. return isset($data['create_time']) ? strtotime($data['create_time']) : 0;
  22. }
  23. }