Skip to content

Commit

Permalink
Merge pull request #917 from LaravelRUS/analysis-z4Orpn
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
Dave authored Aug 12, 2018
2 parents 0e6109c + 83b211b commit 9e31628
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/Form/Element/NamedFormElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

abstract class NamedFormElement extends FormElement
{

use HtmlAttributes;
/**
* @var string
Expand Down Expand Up @@ -304,9 +303,9 @@ public function getValidationRules()
*/
public function resolvePath()
{
$model = $this->getModel();
$model = $this->getModel();
$relations = explode('.', $this->getPath());
$count = count($relations);
$count = count($relations);

if ($count === 1) {
return $model;
Expand Down Expand Up @@ -363,17 +362,15 @@ public function getValueFromModel()
return $value;
}


$model = $this->getModel();
$path = $this->getPath();
$path = $this->getPath();
$value = $this->getDefaultValue();


/**
/*
* Implement json parsing
*/
if (strpos($path, '->') !== false) {
$casts = collect($model->getCasts());
$casts = collect($model->getCasts());
$jsonParts = collect(explode('->', $path));

$jsonAttr = $model->{$jsonParts->first()};
Expand All @@ -394,7 +391,7 @@ public function getValueFromModel()
}

$relations = explode('.', $path);
$count = count($relations);
$count = count($relations);

if ($count === 1) {
$attribute = $model->getAttribute($this->getModelAttributeKey());
Expand All @@ -411,10 +408,10 @@ public function getValueFromModel()
}
if ($count === 2) {
if (str_contains($relation, '->')) {
$parts = explode('->', $relation);
$parts = explode('->', $relation);
$relationField = array_shift($array);
$jsonPath = implode('.', $parts);
$attribute = data_get($model->{$relationField}, $jsonPath);
$jsonPath = implode('.', $parts);
$attribute = data_get($model->{$relationField}, $jsonPath);
} else {
$attribute = $model->getAttribute($relation);
}
Expand Down Expand Up @@ -476,8 +473,8 @@ protected function getModelByPath($path)
$model = $this->getModel();

$relations = explode('.', $path);
$count = count($relations);
$i = 1;
$count = count($relations);
$i = 1;

if ($count > 1) {
$i++;
Expand Down

0 comments on commit 9e31628

Please sign in to comment.