Inove Commerce
Inove Commerce

Reputation: 65

Laravel - Hide model properties in collection

Is there a way to hide the properties of a model, like table, connection, primaryKey, etc in a Laravel collection and keep only the attributes/columns of the table?

                        [table:protected] => product
                        [connection:protected] => mysql
                        [primaryKey:protected] => id
                        [keyType:protected] => int
                        [incrementing] => 1
                        [with:protected] => Array
                            (
                            )

                        [withCount:protected] => Array
                            (
                            )

                        [perPage:protected] => 15
                        [exists] => 1
                        [wasRecentlyCreated] => 
                        [attributes:protected] => Array
                            (
                                ...
                            )

                        [original:protected] => Array
                            (
                                ...
                            )
                       ...
                    )

Upvotes: 1

Views: 828

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

You don't need to do that because these are properties of an Eloquent model object and they will be ignored when you'll serialize the object or convert it to JSON or an array:

$model->toArray()

Upvotes: 2

Related Questions