Skip to content

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

Conversation

pedroluislopez
Copy link

No description provided.

Copy link
Contributor

@jstoone jstoone left a 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. :)

{
return in_array(Str::snake($resourceKey), $record->getDates(), true);
}
else
Copy link
Contributor

@jstoone jstoone Mar 1, 2017

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);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, :)

@pedroluislopez pedroluislopez force-pushed the default-dates-attribute-hydrator branch from bb05d05 to ab0fde8 Compare March 1, 2017 13:45
Copy link
Contributor

@jstoone jstoone left a 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. ❤️

if(is_null($this->dates))
{
return in_array(Str::snake($resourceKey), $record->getDates(), true);
}
return in_array($resourceKey, $this->dates, true);
Copy link
Contributor

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. 😅

@pedroluislopez pedroluislopez force-pushed the default-dates-attribute-hydrator branch from ab0fde8 to b5a01d9 Compare March 1, 2017 13:56
@lindyhopchris
Copy link
Member

This is another great idea. I'll merge it into develop later today or tomorrow.

@lindyhopchris lindyhopchris merged commit 9f585e5 into cloudcreativity:develop Mar 3, 2017
@lindyhopchris
Copy link
Member

This has been released as v0.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants