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.

66 lines
1.3 KiB

  1. <?php
  2. namespace App\Models;
  3. use App\Models\Model;
  4. class System extends Model
  5. {
  6. protected $table = 'systems';
  7. protected $fillable = ['business_id', 'project_id', 'name'];
  8. protected $reportable = [
  9. 'name'
  10. ];
  11. public function rules()
  12. {
  13. return [
  14. 'name' => 'required|string|min:2|max:225',
  15. ];
  16. }
  17. protected $casts = [
  18. 'private' => 'boolean'
  19. ];
  20. public function getValueOf(?string $key)
  21. {
  22. $values = [
  23. 'business_id' => $this->business_id,
  24. 'project_id' => $this->project_id,
  25. 'sprint_id' => null,
  26. 'workflow_id' => null,
  27. 'status_id' => null,
  28. 'system_id' => $this->id,
  29. 'user_id' => null,
  30. 'task_id' => null,
  31. 'subject_id' => $this->id,
  32. ];
  33. if ($key && isset($values, $key)) {
  34. return $values[$key];
  35. }
  36. return $values;
  37. }
  38. public function business()
  39. {
  40. return $this->belongsTo(Business::class, 'business_id', 'id');
  41. }
  42. public function project()
  43. {
  44. return $this->belongsTo(Project::class, 'project_id', 'id');
  45. }
  46. public function tasks()
  47. {
  48. return $this->hasMany(Task::class, 'sub_project_id', 'id');
  49. }
  50. }