SignContract.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 SignContract 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_contracts';
  21. /**
  22. * 为数组 / JSON 序列化准备日期。
  23. *
  24. * @param \DateTimeInterface $date
  25. * @return string
  26. */
  27. protected function serializeDate(DateTimeInterface $date)
  28. {
  29. return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
  30. }
  31. private $statusEnum=[
  32. 0=>'文件生成中',
  33. 1=>'待签署',
  34. 2=>'已签署',
  35. 3=>'已撤销',
  36. 4=>'已拒签',
  37. 5=>'已过期',
  38. 7=>'已拒签',
  39. 10=>'签署失败',
  40. ];
  41. /**
  42. * 序列化数据字典
  43. */
  44. function initializeModel(){
  45. if($this->{'status'}!==null){
  46. $this->{'status_str'}=empty($this->statusEnum[$this->{'status'}])?'无':$this->statusEnum[$this->{'status'}];
  47. }
  48. }
  49. }