|
- <?php
-
- declare(strict_types=1);
-
- namespace App\Models;
-
- class Card
- {
- public int $id = 0;
- public int $boardId = 0;
- public int $columnId = 0;
- public int $swimLaneId = 0;
- public string $jobNumber = '';
- public string $jobName = '';
- public string $customerName = '';
- public ?string $deliveryDate = null;
- public string $quantity = '';
- public string $notes = '';
- public string $fullNote = '';
- public int $position = 0;
- public ?string $createdAt = null;
- public string $createdBy = '';
- public ?string $updatedAt = null;
- public string $updatedBy = '';
-
- public static function fromRow(array $row): self
- {
- $model = new self();
- $model->id = (int) ($row['id'] ?? 0);
- $model->boardId = (int) ($row['board_id'] ?? 0);
- $model->columnId = (int) ($row['column_id'] ?? 0);
- $model->swimLaneId = (int) ($row['swim_lane_id'] ?? 0);
- $model->jobNumber = (string) ($row['job_number'] ?? '');
- $model->jobName = (string) ($row['job_name'] ?? '');
- $model->customerName = (string) ($row['customer_name'] ?? '');
- $model->deliveryDate = $row['delivery_date'] ?: null;
- $model->quantity = (string) ($row['quantity'] ?? '');
- $model->notes = (string) ($row['notes'] ?? '');
- $model->fullNote = (string) ($row['full_note'] ?? '');
- $model->position = (int) ($row['position'] ?? 0);
- $model->createdAt = $row['created_at'] ?? null;
- $model->createdBy = (string) ($row['created_by'] ?? '');
- $model->updatedAt = $row['updated_at'] ?? null;
- $model->updatedBy = (string) ($row['updated_by'] ?? '');
-
- return $model;
- }
-
- public function toJsonArray(): array
- {
- return [
- 'id' => $this->id,
- 'column_id' => $this->columnId,
- 'swim_lane_id' => $this->swimLaneId,
- 'job_number' => $this->jobNumber,
- 'job_name' => $this->jobName,
- 'customer_name' => $this->customerName,
- 'delivery_date' => $this->deliveryDate,
- 'quantity' => $this->quantity,
- 'notes' => $this->notes,
- 'full_note' => $this->fullNote,
- 'position' => $this->position,
- ];
- }
- }
|