-
Notifications
You must be signed in to change notification settings - Fork 107
Use dates attribute from Eloquent model for hydrator by default #52
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
Use dates attribute from Eloquent model for hydrator by default #52
Conversation
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.
Just a little nitpick. :)
src/Hydrator/EloquentHydrator.php
Outdated
{ | ||
return in_array(Str::snake($resourceKey), $record->getDates(), true); | ||
} | ||
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.
There is no need for the else here since you're returning early in the if statement itself. :)
protected function isDateAttribute($record, $resourceKey)
{
if (is_null($this->dates)) {
return in_array(Str::snake($resourceKey), $record->getDates(), true);
}
return in_array($resourceKey, $this->dates, 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.
Ok, :)
bb05d05
to
ab0fde8
Compare
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.
One last change and we're golden. ❤️
src/Hydrator/EloquentHydrator.php
Outdated
if(is_null($this->dates)) | ||
{ | ||
return in_array(Str::snake($resourceKey), $record->getDates(), true); | ||
} | ||
return in_array($resourceKey, $this->dates, 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.
Just one line-break before the return statement, then I'm done OCD'ing all over your code. 😅
ab0fde8
to
b5a01d9
Compare
This is another great idea. I'll merge it into develop later today or tomorrow. |
This has been released as |
No description provided.