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
2.3KB

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Models;
  4. class Card
  5. {
  6. public int $id = 0;
  7. public int $boardId = 0;
  8. public int $columnId = 0;
  9. public int $swimLaneId = 0;
  10. public string $jobNumber = '';
  11. public string $jobName = '';
  12. public string $customerName = '';
  13. public ?string $deliveryDate = null;
  14. public string $quantity = '';
  15. public string $notes = '';
  16. public string $fullNote = '';
  17. public int $position = 0;
  18. public ?string $createdAt = null;
  19. public string $createdBy = '';
  20. public ?string $updatedAt = null;
  21. public string $updatedBy = '';
  22. public static function fromRow(array $row): self
  23. {
  24. $model = new self();
  25. $model->id = (int) ($row['id'] ?? 0);
  26. $model->boardId = (int) ($row['board_id'] ?? 0);
  27. $model->columnId = (int) ($row['column_id'] ?? 0);
  28. $model->swimLaneId = (int) ($row['swim_lane_id'] ?? 0);
  29. $model->jobNumber = (string) ($row['job_number'] ?? '');
  30. $model->jobName = (string) ($row['job_name'] ?? '');
  31. $model->customerName = (string) ($row['customer_name'] ?? '');
  32. $model->deliveryDate = $row['delivery_date'] ?: null;
  33. $model->quantity = (string) ($row['quantity'] ?? '');
  34. $model->notes = (string) ($row['notes'] ?? '');
  35. $model->fullNote = (string) ($row['full_note'] ?? '');
  36. $model->position = (int) ($row['position'] ?? 0);
  37. $model->createdAt = $row['created_at'] ?? null;
  38. $model->createdBy = (string) ($row['created_by'] ?? '');
  39. $model->updatedAt = $row['updated_at'] ?? null;
  40. $model->updatedBy = (string) ($row['updated_by'] ?? '');
  41. return $model;
  42. }
  43. public function toJsonArray(): array
  44. {
  45. return [
  46. 'id' => $this->id,
  47. 'column_id' => $this->columnId,
  48. 'swim_lane_id' => $this->swimLaneId,
  49. 'job_number' => $this->jobNumber,
  50. 'job_name' => $this->jobName,
  51. 'customer_name' => $this->customerName,
  52. 'delivery_date' => $this->deliveryDate,
  53. 'quantity' => $this->quantity,
  54. 'notes' => $this->notes,
  55. 'full_note' => $this->fullNote,
  56. 'position' => $this->position,
  57. ];
  58. }
  59. }

Powered by TurnKey Linux.