Skip to content

Commit 78bc37b

Browse files
committed
Use arrayable for entity list fields
1 parent fb98d86 commit 78bc37b

5 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/EntityList/Fields/EntityListBadgeField.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Code16\Sharp\EntityList\Fields;
44

5-
class EntityListBadgeField implements IsEntityListField
5+
use Illuminate\Contracts\Support\Arrayable;
6+
7+
class EntityListBadgeField implements Arrayable, IsEntityListField
68
{
79
use HasCommonEntityListFieldAttributes;
810

@@ -25,7 +27,7 @@ public function setTooltip(string $tooltip): self
2527
return $this;
2628
}
2729

28-
public function getFieldProperties(): array
30+
public function toArray(): array
2931
{
3032
return [
3133
'type' => 'badge',

src/EntityList/Fields/EntityListField.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Code16\Sharp\EntityList\Fields;
44

5-
class EntityListField implements IsEntityListField
5+
use Illuminate\Contracts\Support\Arrayable;
6+
7+
class EntityListField implements Arrayable, IsEntityListField
68
{
79
use HasCommonEntityListFieldAttributes;
810

@@ -41,7 +43,7 @@ public function setWidthOnSmallScreensFill(): self
4143
return $this;
4244
}
4345

44-
public function getFieldProperties(): array
46+
public function toArray(): array
4547
{
4648
return [
4749
'type' => 'text',

src/EntityList/Fields/EntityListFieldsContainer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ final public function getFields(bool $shouldHaveStateField = false): Collection
7575
$this->fields[] = EntityListStateField::make();
7676
}
7777

78-
return collect($this->fields)
79-
->map(fn (IsEntityListField $field) => $field->getFieldProperties());
78+
return collect($this->fields);
8079
}
8180
}

src/EntityList/Fields/EntityListStateField.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace Code16\Sharp\EntityList\Fields;
44

5-
class EntityListStateField implements IsEntityListField
5+
use Illuminate\Contracts\Support\Arrayable;
6+
7+
class EntityListStateField implements Arrayable, IsEntityListField
68
{
79
use HasCommonEntityListFieldAttributes;
810

@@ -13,7 +15,7 @@ public static function make(): static
1315
return new static();
1416
}
1517

16-
public function getFieldProperties(): array
18+
public function toArray(): array
1719
{
1820
return [
1921
'type' => 'state',

src/EntityList/Fields/IsEntityListField.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
interface IsEntityListField
66
{
7-
public function getFieldProperties(): array;
8-
97
public function setLabel(string $label): self;
108

119
public function setSortable(bool $sortable = true): self;

0 commit comments

Comments
 (0)