Closed buttflattery closed 6 years ago
The docs could be a bit misleading for anyone who just copy pastes the example.
It uses compact
which will ignore any variables it can't find.
This won't work
{
$model = new DynamicModel(compact('finance_needed'));
print_r($model->attributes);
}
While this will
{
$finance_needed = 'my value here';
$model = new DynamicModel(compact('finance_needed'));
print_r($model->attributes);
}
If you don't need to provide values during initialisation then just pass the attribute name as you have new DynamicModel(['finance_needed']);
Thanks for reporting.
As per documentation for the DynamicModel under Adhoc Validation example hows attributes being passed to the model as
new DynamicModel(compact('attribute_name_1','attribute_name_2'))
where as this does not work and does not declare the model attributesWhat steps will reproduce the problem?
What is the expected result?
it should display
What do you get instead?
It shows empty array as if no attributes were declared if i try to validate like this it throws the exception
Additional info
If i change it to a normal array like below
new DynamicModel(['finance_needed']);
then it works correctly and declare the attribute for the model