Property does not exist on this collection instance
I’m getting this error on my Laravel app:
Property [hide_navigation] does not exist on this collection instance
This my query:
$hideNavCheck = DB::table('custom_pages')->get();
The error message you are seeing indicates that the property “hide_navigation” does not exist on the collection instance returned by your query. This means that you are trying to access a property that does not exist on the object.
Based on the code you provided, it seems that you are retrieving data from a “custom_pages” table using Laravel’s Query Builder. When you call the “get()” method, it returns a collection instance which represents a set of results from the database.
It is possible that the “hide_navigation” property exists in your database table, but you are not selecting it in your query. To access this property, you would need to modify your query to include it in the select statement. For example:
$hideNavCheck = DB::table('custom_pages')->select('hide_navigation')->get();
This would return a collection of objects, each containing a “hide_navigation” property that you can access.
Alternatively, if you do not need the entire collection of objects and just want to check if any of them have the “hide_navigation” property, you could use the “pluck()” method to retrieve a specific column from the table:
$hideNavCheck = DB::table('custom_pages')->pluck('hide_navigation');
This would return a collection of values for the “hide_navigation” column, which you can then check for the existence of a specific value.