Status.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/6/6
  6. * Time: 下午4:11
  7. */
  8. namespace app\common\models;
  9. use app\common\modules\status\StatusObserverDispatcher;
  10. use Illuminate\Database\Eloquent\SoftDeletes;
  11. /**
  12. * 状态
  13. * Class State
  14. * @package app\common\models\statusFlow
  15. * @property int id
  16. * @property int order
  17. * @property string code
  18. * @property string name
  19. * @property Flow flow
  20. */
  21. class Status extends BaseModel
  22. {
  23. use SoftDeletes;
  24. public $table = 'yz_status';
  25. protected $guarded = ['id'];
  26. protected $fillable = ['name', 'code', 'order', 'plugin_id'];
  27. const ORDER_CLOSE = -2;
  28. const ORDER_CANCEL = -1;
  29. /**
  30. * 包含此状态的流程
  31. * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
  32. */
  33. public function flow()
  34. {
  35. return $this->belongsTo(Flow::class, 'flow_id');
  36. }
  37. /**
  38. * @return string
  39. */
  40. public function getFullCodeAttribute()
  41. {
  42. return $this->flow->code . '.' . $this->code;
  43. }
  44. }