SignRecord.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Models;
  3. use DateTimeInterface;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Database\Eloquent\Model;
  6. /**
  7. * App\Models\Contract
  8. *
  9. * @mixin \Eloquent
  10. */
  11. class SignRecord extends Model
  12. {
  13. use HasFactory;
  14. protected $guarded = ['id', 'updated_at', 'created_at'];
  15. /**
  16. * The table associated with the model.
  17. *
  18. * @var string
  19. */
  20. protected $table = 'sign_records';
  21. private $statusEnum=[
  22. 0=>'文件生成中',
  23. 1=>'待签署',
  24. 2=>'已签署',
  25. 3=>'已撤销',
  26. 4=>'已拒签',
  27. 5=>'已过期',
  28. 7=>'已拒签',
  29. 10=>'签署失败',
  30. ];
  31. /**
  32. * 序列化数据字典
  33. */
  34. function initializeModel(){
  35. if($this->{'status'}!==null){
  36. $this->{'status_str'}=empty($this->statusEnum[$this->{'status'}])?'无':$this->statusEnum[$this->{'status'}];
  37. }
  38. }
  39. /**
  40. * 为数组 / JSON 序列化准备日期。
  41. *
  42. * @param \DateTimeInterface $date
  43. * @return string
  44. */
  45. protected function serializeDate(DateTimeInterface $date)
  46. {
  47. return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
  48. }
  49. }