Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanjansen committed Jan 31, 2023
1 parent 0dc9cfa commit 0efe3e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/DataTransferObjects/MediaCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public function current(): MediaData
return parent::current();
}

public static function createSingle($data)
{
return static::create([$data]);
}

public static function create($data)
{
if ($data instanceof MediaCollection) {
Expand Down
11 changes: 7 additions & 4 deletions src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ public function __construct(string $name, string $attribute = null, callable $va
}
}

public function setName(string $name): static
{
$this->name = $name;

return $this;
}

public function valueCallback(callable $valueCallback = null)
{
$this->valueCallback = $valueCallback;
Expand Down Expand Up @@ -314,10 +321,6 @@ public function fillFromResource($resource, $defaultValue = null): void

$value = $this->getResourceAttributeValue($resource, $this->attribute) ?: $defaultValue;

if ($this->attribute === 'description') {
dd($value);
}

$this->value = $this->valueCallback
? tap($value, fn ($value) => call_user_func(
$this->valueCallback,
Expand Down

0 comments on commit 0efe3e9

Please sign in to comment.