Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -41,7 +41,39 @@ trait FormAccessible
return $this->mutateFormAttribute($key, $value);
}
return $value;
$keys = explode('.', $key);
if ($this->isNestedModel($keys[0])) {
$relatedModel = $this->getRelation($keys[0]);
unset($keys[0]);
$key = implode('.', $keys);
if ($this->hasFormMutator($key)) {
return $relatedModel->getFormValue($key);
}
return data_get($relatedModel, $key);
}
// No form mutator, let the model resolve this
return data_get($this, $key);
}
/**
* Check for a nested model.
*
* @param string $key
*
* @return bool
*/
public function isNestedModel($key)
{
if (in_array($key, array_keys($this->getRelations()))) {
return true;
}
return false;
}
/**
@@ -54,8 +86,8 @@ trait FormAccessible
$methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC);
$mutator = collect($methods)
->first(function ($index, ReflectionMethod $method) use ($key) {
return $method->getName() == 'form' . Str::studly($key) . 'Attribute';
->first(function (ReflectionMethod $method) use ($key) {
return $method->getName() === 'form' . Str::studly($key) . 'Attribute';
});
return (bool) $mutator;