-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing notes typecast issue #34
Conversation
src/Entity.php
Outdated
if (in_array($data['entity'], $entities)) | ||
$entity = $data; | ||
} | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
src/Entity.php
Outdated
{ | ||
$entities = static::getDefinedEntitiesArray(); | ||
|
||
if (isset($data['entity'])) | ||
if (self::isNotes($key) === true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a generic isArrayableAttribute function.
Shift 'notes' to an array in the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
src/Entity.php
Outdated
@@ -138,7 +155,7 @@ public function fill($data) | |||
{ | |||
if (is_array($v)) | |||
{ | |||
$entity = static::buildEntity($v); | |||
$entity = static::buildEntity($key, $v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a separate function for filling a single key => value pair.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored. Added a helper for the associate array case as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Entity.php
Outdated
{ | ||
$entities = static::getDefinedEntitiesArray(); | ||
|
||
if (isset($data['entity'])) | ||
if (self::isNotes($key) === true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
src/Entity.php
Outdated
if (in_array($data['entity'], $entities)) | ||
$entity = $data; | ||
} | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored
src/Entity.php
Outdated
@@ -138,7 +155,7 @@ public function fill($data) | |||
{ | |||
if (is_array($v)) | |||
{ | |||
$entity = static::buildEntity($v); | |||
$entity = static::buildEntity($key, $v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored. Added a helper for the associate array case as well.
@shashankkumar @73SL4 Kindly review. |
@@ -67,15 +67,21 @@ protected function request($method, $relativeUrl, $data = null) | |||
} | |||
else | |||
{ | |||
return static::buildEntity($response); | |||
return static::buildEntity(null, $response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@captn3m0 not sure if it's a good idea to pass null. Was thinking if we can make key as the second argument. What do you think?
Will reopen if needed. |
[notes typecase] Hardcoding notes to be an array