From 79788af175d33e5cfb77f6c7f8dd308b5d4443bc Mon Sep 17 00:00:00 2001 From: Jimmy Puckett Date: Sun, 6 Apr 2025 16:42:32 -0400 Subject: [PATCH 1/4] Set type in collection --- src/Support/Builder.php | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Support/Builder.php b/src/Support/Builder.php index 831de62..dd94010 100644 --- a/src/Support/Builder.php +++ b/src/Support/Builder.php @@ -47,36 +47,36 @@ * Class Builder * * @property Agent $agent - * @property Collection $actions - * @property Collection $agents - * @property Collection $appointments - * @property Collection $articles - * @property Collection $assets - * @property Collection $asset_types - * @property Collection $attachments - * @property Collection $clients - * @property Collection $contracts - * @property Collection $invoices - * @property Collection $items - * @property Collection $opportunities - * @property Collection $organisations - * @property Collection $priorities - * @property Collection $projects - * @property Collection $quotes - * @property Collection $reports - * @property Collection $sites - * @property Collection $slas - * @property Collection $statuses - * @property Collection $suppliers - * @property Collection $teams - * @property Collection $ticket_types - * @property Collection $tickets - * @property Collection $users - * @property Collection $webhook_events - * @property Collection $webhooks - * @property Collection $workdays - * @property User $user * @property Client $client + * @property Collection $actions + * @property Collection $agents + * @property Collection $appointments + * @property Collection $articles + * @property Collection $asset_types + * @property Collection $assets + * @property Collection $attachments + * @property Collection $clients + * @property Collection $contracts + * @property Collection $invoices + * @property Collection $items + * @property Collection $opportunities + * @property Collection $organisations + * @property Collection $priorities + * @property Collection $projects + * @property Collection $quotes + * @property Collection $reports + * @property Collection $sites + * @property Collection $slas + * @property Collection $statuses + * @property Collection $suppliers + * @property Collection $teams + * @property Collection $ticket_types + * @property Collection $tickets + * @property Collection $users + * @property Collection $webhook_events + * @property Collection $webhooks + * @property Collection $workdays + * @property User $user * * @method self actions() * @method self agents() From a9310d79271ab7afa4f97789858bc116bf57344e Mon Sep 17 00:00:00 2001 From: Jimmy Puckett Date: Sun, 6 Apr 2025 16:42:54 -0400 Subject: [PATCH 2/4] Add model for software licenses --- src/SoftwareLicence.php | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/SoftwareLicence.php diff --git a/src/SoftwareLicence.php b/src/SoftwareLicence.php new file mode 100644 index 0000000..79b357b --- /dev/null +++ b/src/SoftwareLicence.php @@ -0,0 +1,68 @@ + 'datetime', + 'requested_quantity_date' => 'datetime', + 'start_date' => 'datetime', + ]; + + /** + * Some of the responses have the data under a property + */ + protected ?string $responseKey = 'licences'; + + /** + * Path to API endpoint. + */ + protected string $path = '/softwarelicence'; +} From 46fbae3a62e8333c2838065be96d5c94c1a13512 Mon Sep 17 00:00:00 2001 From: Jimmy Puckett Date: Sun, 6 Apr 2025 16:43:06 -0400 Subject: [PATCH 3/4] Hook up model to builder --- src/Support/Builder.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Support/Builder.php b/src/Support/Builder.php index dd94010..ddc3021 100644 --- a/src/Support/Builder.php +++ b/src/Support/Builder.php @@ -33,6 +33,7 @@ use Spinen\Halo\Report; use Spinen\Halo\Site; use Spinen\Halo\Sla; +use Spinen\Halo\SoftwareLicence; use Spinen\Halo\Status; use Spinen\Halo\Supplier; use Spinen\Halo\Team; @@ -67,6 +68,7 @@ * @property Collection $reports * @property Collection $sites * @property Collection $slas + * @property Collection $software_licences * @property Collection $statuses * @property Collection $suppliers * @property Collection $teams @@ -99,6 +101,7 @@ * @method self search($for) * @method self sites() * @method self slas() + * @method self software_licences() * @method self statuses() * @method self suppliers() * @method self teams() @@ -160,6 +163,7 @@ class Builder 'reports' => Report::class, 'sites' => Site::class, 'slas' => Sla::class, + 'software_licences' => SoftwareLicence::class, 'statuses' => Status::class, 'suppliers' => Supplier::class, 'teams' => Team::class, From 15191e2891aacae16508ee32c05711426df0f167 Mon Sep 17 00:00:00 2001 From: Jimmy Puckett Date: Sun, 6 Apr 2025 16:43:15 -0400 Subject: [PATCH 4/4] Denote a todo --- src/Support/Model.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Support/Model.php b/src/Support/Model.php index ba36f0e..10575bd 100644 --- a/src/Support/Model.php +++ b/src/Support/Model.php @@ -568,6 +568,9 @@ public function newFromBuilder($attributes = []): self { $model = $this->newInstance([], true); + // TODO: Should we add a way to transform values? + // (i.e. SoftwareLicence gives 1899-12-30 00:00:00 for null date) + $model->setRawAttributes((array) $attributes, true); return $model;