You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

  1. <?php
  2. namespace App;
  3. use App\HiLib\Models\Model;
  4. use Illuminate\Validation\Rule;
  5. class Status extends Model
  6. {
  7. protected $table = 'statuses';
  8. protected $fillable = [
  9. 'business_id', 'workflow_id', 'name', 'state', 'order'
  10. ];
  11. protected $reportable = [
  12. 'name', 'state', 'order'
  13. ];
  14. public function rules()
  15. {
  16. return [
  17. 'name' =>'required|string|min:3|max:255',
  18. 'state' => 'nullable|between:0,3',
  19. 'order' => 'nullable|numeric|min:0'
  20. ];
  21. }
  22. public function getValueOf(?string $key)
  23. {
  24. $values = [
  25. 'business_id' => $this->business_id,
  26. 'project_id' => null,
  27. 'sprint_id' => null,
  28. 'workflow_id' => $this->workflow_id,
  29. 'status_id' => $this->id,
  30. 'system_id' => null,
  31. 'user_id' => null,
  32. 'task_id' => null,
  33. 'subject_id' => $this->id,
  34. ];
  35. if ($key && isset($values, $key)) {
  36. return $values[$key];
  37. }
  38. return $values;
  39. }
  40. public function workflow()
  41. {
  42. return $this->belongsTo(Workflow::class,'workflow_id','id');
  43. }
  44. }