Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update HandlesBoundValues.php
  • Loading branch information
pascalbaljet committed Dec 22, 2020
commit 78e6b75076c5ce9b43d0c4ae5b330642bb6ce08d
19 changes: 17 additions & 2 deletions src/Components/HandlesBoundValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

trait HandlesBoundValues
{
/**
* Wether to retrieve the default value as a single
* attribute or as a collection from the database.
*
* @var boolean
*/
protected $manyRelation = false;

/**
Expand Down Expand Up @@ -51,10 +57,17 @@ private function getBoundValue($bind, string $name)
: data_get($bind, $name);
}

private function getAttachedKeysFromRelation($bind, string $name)
/**
* Returns an array with the attached keys.
*
* @param mixed $bind
* @param string $name
* @return void
*/
private function getAttachedKeysFromRelation($bind, string $name): ?array
{
if (!$bind instanceof Model) {
return;
return data_get($bind, $name);
}

$relation = $bind->{$name}();
Expand All @@ -76,5 +89,7 @@ private function getAttachedKeysFromRelation($bind, string $name)
->pluck($parentKeyName)
->all();
}

return data_get($bind, $name);
}
}