wip: continue implementation
This commit is contained in:
@@ -2,10 +2,18 @@
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
class Availability
|
||||
class Availability implements \JsonSerializable
|
||||
{
|
||||
public ?int $serviceId = null;
|
||||
public ?string $status = null;
|
||||
public ?int $available = null;
|
||||
public ?float $price = null;
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->serviceId,
|
||||
'available' => $this->available,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
class CrmAction
|
||||
{
|
||||
public ?int $id = null;
|
||||
public ?string $code = null;
|
||||
public ?string $label = null;
|
||||
public bool $mutable = false;
|
||||
public bool $selected = false;
|
||||
}
|
||||
@@ -5,30 +5,10 @@ namespace App\BusProNet\Model;
|
||||
class CrmAttributes
|
||||
{
|
||||
public ?array $selectionGroups = null;
|
||||
public ?array $crmActions = null;
|
||||
public bool $admin = false;
|
||||
public bool $manager = false;
|
||||
public bool $houseManager = false;
|
||||
public bool $teamer = false;
|
||||
public ?string $hotelCode = null;
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$crmSelections = [];
|
||||
|
||||
foreach ($this->selectionGroups as $group) {
|
||||
/** @var CrmSelectionGroup $group */
|
||||
if (false === isset($crmSelections[$group->label])) {
|
||||
$crmSelections[$group->label] = [];
|
||||
}
|
||||
foreach ($group->selections as $attribute) {
|
||||
/** @var CrmSelection $attribute */
|
||||
if (false === $attribute->selected) {
|
||||
continue;
|
||||
}
|
||||
$crmSelections[$group->label][] = $attribute->label;
|
||||
}
|
||||
}
|
||||
|
||||
return $crmSelections;
|
||||
}
|
||||
}
|
||||
@@ -6,5 +6,6 @@ class CrmSelection
|
||||
{
|
||||
public ?int $id = null;
|
||||
public ?string $label = null;
|
||||
public bool $mutable = false;
|
||||
public bool $selected = false;
|
||||
}
|
||||
@@ -19,4 +19,16 @@ class CrmSelectionGroup
|
||||
public ?int $id = null;
|
||||
public ?string $label = null;
|
||||
public ?array $selections = null;
|
||||
|
||||
public function getMutableSelections(): array
|
||||
{
|
||||
return array_filter($this->selections, function (CrmSelection $selection) {
|
||||
return $selection->mutable;
|
||||
});
|
||||
}
|
||||
|
||||
public function isVisible(): bool
|
||||
{
|
||||
return 0 < count($this->getMutableSelections());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user