How to fix “trying to get property of non-object” with PHP8 in Laravel

If you’re tired of the error “trying to get property of non-object”, you could use an optional helper method in Laravel. Also, if you’re using PHP8+ you could find the better way of dealing with these issues with the nullsafe operator. Here we go: You can read the official PHP reference on this operator here […]