A couple of ways come to mind. There's the property_exists function - here's the link to it. You can scatter this around your application, or you can look into the magic __get function. Here's the link. You can couple the __get with the property_exists function to return null or blank if it doesn't exist on the object, thus eliminating your issue.
You may want to throw this functionality in a trait for reuse-ability too.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community