|
- <?php
-
- declare(strict_types=1);
-
- namespace App\Models;
-
- class CardMovement
- {
- public int $id = 0;
- public int $cardId = 0;
- public ?int $fromColumnId = null;
- public ?string $fromColumnName = null;
- public int $toColumnId = 0;
- public ?string $toColumnName = null;
- public ?int $fromSwimLaneId = null;
- public ?string $fromSwimLaneName = null;
- public int $toSwimLaneId = 0;
- public ?string $toSwimLaneName = null;
- public string $movedAt = '';
- public string $movedBy = '';
-
- public static function fromRow(array $row): self
- {
- $model = new self();
- $model->id = (int) ($row['id'] ?? 0);
- $model->cardId = (int) ($row['card_id'] ?? 0);
- $model->fromColumnId = isset($row['from_column_id']) ? (int) $row['from_column_id'] : null;
- $model->fromColumnName = $row['from_column_name'] ?? null;
- $model->toColumnId = (int) ($row['to_column_id'] ?? 0);
- $model->toColumnName = $row['to_column_name'] ?? null;
- $model->fromSwimLaneId = isset($row['from_swim_lane_id']) ? (int) $row['from_swim_lane_id'] : null;
- $model->fromSwimLaneName = $row['from_swim_lane_name'] ?? null;
- $model->toSwimLaneId = (int) ($row['to_swim_lane_id'] ?? 0);
- $model->toSwimLaneName = $row['to_swim_lane_name'] ?? null;
- $model->movedAt = (string) ($row['moved_at'] ?? '');
- $model->movedBy = (string) ($row['moved_by'] ?? '');
-
- return $model;
- }
-
- public function toJsonArray(): array
- {
- return [
- 'id' => $this->id,
- 'from_column_id' => $this->fromColumnId,
- 'from_column_name' => $this->fromColumnName,
- 'to_column_id' => $this->toColumnId,
- 'to_column_name' => $this->toColumnName,
- 'from_swim_lane_id' => $this->fromSwimLaneId,
- 'from_swim_lane_name' => $this->fromSwimLaneName,
- 'to_swim_lane_id' => $this->toSwimLaneId,
- 'to_swim_lane_name' => $this->toSwimLaneName,
- 'moved_at' => $this->movedAt,
- 'moved_by' => $this->movedBy,
- ];
- }
- }
|