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.

53 lines
1.1 KiB

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