Skip to content

Commit

Permalink
Merge pull request #421 from sdapkus/0.x-fix
Browse files Browse the repository at this point in the history
#419 fix
  • Loading branch information
voidgraphics authored Dec 6, 2022
2 parents c62f87e + 25b2cce commit 20bee1b
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/Layouts/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ class Layout implements LayoutInterface, JsonSerializable, ArrayAccess, Arrayabl
*/
protected $model;

/**
* The relation resolver callbacks for the Layout.
*
* @var array
*/
protected $relationResolvers = [];

/**
* The loaded relationships for the Layout.
*
* @var array
*/
protected $relations = [];

/**
* Create a new base Layout instance
*
Expand Down Expand Up @@ -245,7 +259,7 @@ public function duplicateAndHydrate($key, array $attributes = [])
$fields = $this->fields->map(function($field) {
return $this->cloneField($field);
});

$clone = new static(
$this->title,
$this->name,
Expand Down Expand Up @@ -279,7 +293,7 @@ protected function cloneField(Field $original) {

return $field;
}

/**
* Resolve fields using given attributes.
*
Expand Down Expand Up @@ -519,7 +533,7 @@ public function offsetSet($offset, $value)
* @param mixed $offset
* @return void
*/
#[\ReturnTypeWillChange]
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->attributes[$offset]);
Expand Down Expand Up @@ -603,6 +617,20 @@ protected function relationLoaded()
return false;
}

/**
* Get the dynamic relation resolver if defined or inherited, or return null.
* Since it is not possible to define a relation on a layout, this method
* returns null
*
* @param string $class
* @param string $key
* @return mixed
*/
public function relationResolver($class, $key)
{
return null;
}

/**
* Transform layout for serialization
*
Expand Down

0 comments on commit 20bee1b

Please sign in to comment.