From 2e12ee07e3e7750bb48ded13f87bd43a41c40878 Mon Sep 17 00:00:00 2001 From: Michael Dyrynda Date: Thu, 29 Jan 2015 15:19:17 +1030 Subject: [PATCH] If using the 'or' Laravel Blade syntax, a call such as {{ $model->present()->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. --- src/Laracasts/Presenter/Presenter.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Laracasts/Presenter/Presenter.php b/src/Laracasts/Presenter/Presenter.php index 54c4cb7..c4c46b7 100644 --- a/src/Laracasts/Presenter/Presenter.php +++ b/src/Laracasts/Presenter/Presenter.php @@ -31,4 +31,16 @@ public function __get($property) return $this->entity->{$property}; } -} \ No newline at end of file + + /** + * Provide compatibility for the 'or' syntax in Blade templates + * + * @param $property + * @return boolean + */ + public function __isset($property) + { + return method_exists($this, $property); + } + +}