Skip to content

Commit

Permalink
Added InvalidArgumentException (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
ukeloop authored Apr 17, 2023
1 parent f714e49 commit 60a198a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Kris/LaravelFormBuilder/Fields/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ protected function pluck($value, $key, $data)
//laravel 5.2.*
return $data->lists($value, $key);
}

throw new \InvalidArgumentException(sprintf(
'Please provide valid "property" option for entity field [%s] in form class [%s]',
$this->getRealName(),
get_class($this->parent)
));
}

protected function get($data)
Expand All @@ -115,5 +121,11 @@ protected function get($data)
//laravel 5.3.*
return $data->get();
}

throw new \InvalidArgumentException(sprintf(
'Please provide valid "query_builder" option for entity field [%s] in form class [%s]',
$this->getRealName(),
get_class($this->parent)
));
}
}
15 changes: 13 additions & 2 deletions src/Kris/LaravelFormBuilder/Fields/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,24 @@ protected function getRenderData()
protected function getModelValueAttribute($model, $name)
{
$transformedName = $this->transformKey($name);

if (is_null($model)) {
return null;
}

if (is_string($model)) {
return $model;
} elseif (is_object($model)) {
}

if (is_object($model)) {
return object_get($model, $transformedName);
} elseif (is_array($model)) {
}

if (is_array($model)) {
return Arr::get($model, $transformedName);
}

throw new \InvalidArgumentException('Invalid model given to field');
}

/**
Expand Down

0 comments on commit 60a198a

Please sign in to comment.