Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

58 рядки
2.2KB

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Models;
  4. class CardMovement
  5. {
  6. public int $id = 0;
  7. public int $cardId = 0;
  8. public ?int $fromColumnId = null;
  9. public ?string $fromColumnName = null;
  10. public int $toColumnId = 0;
  11. public ?string $toColumnName = null;
  12. public ?int $fromSwimLaneId = null;
  13. public ?string $fromSwimLaneName = null;
  14. public int $toSwimLaneId = 0;
  15. public ?string $toSwimLaneName = null;
  16. public string $movedAt = '';
  17. public string $movedBy = '';
  18. public static function fromRow(array $row): self
  19. {
  20. $model = new self();
  21. $model->id = (int) ($row['id'] ?? 0);
  22. $model->cardId = (int) ($row['card_id'] ?? 0);
  23. $model->fromColumnId = isset($row['from_column_id']) ? (int) $row['from_column_id'] : null;
  24. $model->fromColumnName = $row['from_column_name'] ?? null;
  25. $model->toColumnId = (int) ($row['to_column_id'] ?? 0);
  26. $model->toColumnName = $row['to_column_name'] ?? null;
  27. $model->fromSwimLaneId = isset($row['from_swim_lane_id']) ? (int) $row['from_swim_lane_id'] : null;
  28. $model->fromSwimLaneName = $row['from_swim_lane_name'] ?? null;
  29. $model->toSwimLaneId = (int) ($row['to_swim_lane_id'] ?? 0);
  30. $model->toSwimLaneName = $row['to_swim_lane_name'] ?? null;
  31. $model->movedAt = (string) ($row['moved_at'] ?? '');
  32. $model->movedBy = (string) ($row['moved_by'] ?? '');
  33. return $model;
  34. }
  35. public function toJsonArray(): array
  36. {
  37. return [
  38. 'id' => $this->id,
  39. 'from_column_id' => $this->fromColumnId,
  40. 'from_column_name' => $this->fromColumnName,
  41. 'to_column_id' => $this->toColumnId,
  42. 'to_column_name' => $this->toColumnName,
  43. 'from_swim_lane_id' => $this->fromSwimLaneId,
  44. 'from_swim_lane_name' => $this->fromSwimLaneName,
  45. 'to_swim_lane_id' => $this->toSwimLaneId,
  46. 'to_swim_lane_name' => $this->toSwimLaneName,
  47. 'moved_at' => $this->movedAt,
  48. 'moved_by' => $this->movedBy,
  49. ];
  50. }
  51. }

Powered by TurnKey Linux.