Device.php 638 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class Device extends Model
  6. {
  7. protected $table = 'device';
  8. protected $primaryKey = 'device_id';
  9. protected $keyType = 'string';
  10. protected $dateFormat = 'U';
  11. const CREATED_AT = 'device_addtimes';
  12. const UPDATED_AT = null;
  13. public function serializeDate(DateTimeInterface $date)
  14. {
  15. return $date->format('Y-m-d H:i:s');
  16. }
  17. public function ledger()
  18. {
  19. return $this->hasOne(DeviceLedger::class, 'device_ledger_id', 'join_device_ledger_id')
  20. ->select('device_ledger_id', 'device_ledger_name');
  21. }
  22. }