Skip to content

[7.x] Added makeVisibleIf and makeHiddenIf - #33176

Merged
taylorotwell merged 2 commits into
laravel:7.xfrom
rennokki:feature/make-if
Jun 11, 2020
Merged

[7.x] Added makeVisibleIf and makeHiddenIf#33176
taylorotwell merged 2 commits into
laravel:7.xfrom
rennokki:feature/make-if

Conversation

@rennokki

Copy link
Copy Markdown
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