Skip to content

Correct isset behaviour#27

Open
michaeldyrynda wants to merge 1 commit into
laracasts:masterfrom
michaeldyrynda:master
Open

Correct isset behaviour#27
michaeldyrynda wants to merge 1 commit into
laracasts:masterfrom
michaeldyrynda:master

Conversation

@michaeldyrynda

Copy link
Copy Markdown
Contributor

In order to be able to use ternary / Laravel Blade or syntax, provide an __isset magic method.

@kylestev

kylestev commented Feb 7, 2015

Copy link
Copy Markdown

👍 this looks good to me and makes sense.

@ChrisReid

Copy link
Copy Markdown

It would also need to return true if the property exists on the model. Sometimes you might not override a model property and you would want it to show as set.

@michaeldyrynda

Copy link
Copy Markdown
Contributor Author

If you weren't changing the property that's on the model, wouldn't you just display that directly ($model->property rather than $model->present()->property)?

@jordanlev

Copy link
Copy Markdown

+1 ... this is also required when using presenter models in Twig templates (because Twig won't bother asking for a property or method unless it passes an isset check first)

…sent()->property or "N/A" }} will return false for a property retrieved via the __get magic method.

Provide an __isset magic method to correct this behaviour.
@michaeldyrynda michaeldyrynda force-pushed the master branch 2 times, most recently from 7d96a6c to 2e12ee0 Compare February 16, 2022 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants