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.

69 lines
1.3 KiB

  1. <?php
  2. namespace App;
  3. use App\HiLib\Models\Model;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Validation\Rule;
  6. class System extends Model
  7. {
  8. protected $table = 'systems';
  9. protected $fillable = ['business_id', 'project_id', 'name'];
  10. protected $reportable = [
  11. 'name'
  12. ];
  13. public function rules()
  14. {
  15. return [
  16. 'name' => 'required|string|min:2|max:225',
  17. ];
  18. }
  19. protected $casts = [
  20. 'private' => 'boolean'
  21. ];
  22. public function getValueOf(?string $key)
  23. {
  24. $values = [
  25. 'business_id' => $this->business_id,
  26. 'project_id' => $this->project_id,
  27. 'sprint_id' => null,
  28. 'workflow_id' => null,
  29. 'status_id' => null,
  30. 'system_id' => $this->id,
  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 business()
  41. {
  42. return $this->belongsTo(Business::class, 'business_id', 'id');
  43. }
  44. public function project()
  45. {
  46. return $this->belongsTo(Project::class, 'project_id', 'id');
  47. }
  48. public function tasks()
  49. {
  50. return $this->hasMany(Task::class, 'sub_project_id', 'id');
  51. }
  52. }