Skip to content
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

[7.x] Added makeVisibleIf and makeHiddenIf #33176

Merged
merged 2 commits into from
Jun 11, 2020
Merged

[7.x] Added makeVisibleIf and makeHiddenIf #33176

merged 2 commits into from
Jun 11, 2020

Conversation

rennokki
Copy link
Contributor

What I want to achieve is to show/hide certain attributes based on other model attributes.

For example, hiding home_lineups and away_lineups for a sport event if they don't have lineups.

$sportEvent->makeHiddenIf(function ($sportEvent) {
    return ! $sportEvent->has_lineups;
}, ['home_lineups, 'away_lineups']);

Or, vice-versa, having them hidden by default and showing them:

$sportEvent->makeVisibleIf(function ($sportEvent) {
    return $sportEvent->has_lineups;
}, ['home_lineups, 'away_lineups']);

@rennokki rennokki changed the title Added makeVisibleIf and makeHiddenIf [7.x] Added makeVisibleIf and makeHiddenIf Jun 10, 2020
@taylorotwell taylorotwell merged commit 7ad6a1d into laravel:7.x Jun 11, 2020
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.

2 participants