ProcessModel.php 814 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\process\models;
  3. use app\framework\Model\SimpleModel;
  4. use Carbon\Carbon;
  5. use Illuminate\Support\Facades\Redis;
  6. /**
  7. * Class ProcessModel
  8. * @package app\process\models
  9. * @property int pid
  10. * @property int createdAt
  11. * @property string runningTime
  12. */
  13. class ProcessModel extends SimpleModel
  14. {
  15. public $attributeTypes = [
  16. 'pid' => 'int',
  17. 'createdAt' => 'timestamp',
  18. 'runningTime' => 'string',
  19. ];
  20. public $attributes = [
  21. 'pid'=>0,
  22. 'createdAt'=>null,
  23. 'runningTime'=>null,
  24. ];
  25. protected function getCreatedAtAttribute()
  26. {
  27. return Redis::hget('ProcessData', $this->pid);
  28. }
  29. protected function getRunningTimeAttribute()
  30. {
  31. return Carbon::createFromTimestamp($this->createdAt)->diffForHumans();
  32. }
  33. }