Scenario.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php /** Created by Anton on 11.02.2020. */
  2. namespace app\models\entity\ar;
  3. use app\models\entity\Tasks;
  4. use app\models\entity\Tasktypes;
  5. use yii\db\ActiveRecord;
  6. /**
  7. * This is the model class for table "ar_scenarios".
  8. *
  9. * @property int $id
  10. * @property string $name [varchar(155)]
  11. * @property int $status
  12. * @property-read Stage[] $stages
  13. * @property-read Tasks[] $tasks
  14. * @property-read Tasktypes[] $tasktypes
  15. */
  16. class Scenario extends ActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return 'ar_scenarios';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [];
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function attributeLabels()
  36. {
  37. return [
  38. 'id' => 'ID',
  39. 'name' => 'Название сценария',
  40. ];
  41. }
  42. public function getStages()
  43. {
  44. return $this->hasMany(Stage::class, ['scenario_id' => 'id']);
  45. }
  46. public function getTasks()
  47. {
  48. return $this->hasMany(Tasks::class, ['scenario_id' => 'id']);
  49. }
  50. public function getTasktypes()
  51. {
  52. return $this->hasMany(Tasktypes::class, ['scenario_id' => 'id']);
  53. }
  54. public function fillFromArray($params)
  55. {
  56. $this->name = $params['name'];
  57. }
  58. public function asArray()
  59. {
  60. return [
  61. 'id' => $this->id,
  62. 'name' => $this->name
  63. ];
  64. }
  65. }