Skip to content

Commit 2e12ee0

Browse files
Michael Dyryndamichaeldyrynda
Michael Dyrynda
authored andcommitted
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.
1 parent 65fd3a7 commit 2e12ee0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Laracasts/Presenter/Presenter.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,16 @@ public function __get($property)
3131
return $this->entity->{$property};
3232
}
3333

34-
}
34+
35+
/**
36+
* Provide compatibility for the 'or' syntax in Blade templates
37+
*
38+
* @param $property
39+
* @return boolean
40+
*/
41+
public function __isset($property)
42+
{
43+
return method_exists($this, $property);
44+
}
45+
46+
}

0 commit comments

Comments
 (0)