ali_254 Posted April 16, 2022 Share Posted April 16, 2022 (edited) hi. I wrote this code and printed it: $category=Category::find(16); dd($category); The result: (The result of executing the above code , return an object of the category class.) App\Models\Category {#1353 ▼ #connection: "mysql" #table: "categories" #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] +preventsLazyLoading: false #perPage: 15 +exists: true +wasRecentlyCreated: false #escapeWhenCastingToString: false #attributes: array:5 [▶] #original: array:5 [▶] #changes: [] #casts: [] #classCastCache: [] #attributeCastCache: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #hidden: [] #visible: [] #fillable: array:2 [▶] #guarded: array:1 [▶] } but , When I run this code: $category=Category::find(16); $class_vars = get_object_vars($category); dd($class_vars); result: array:5 [▼ "incrementing" => true "preventsLazyLoading" => false "exists" => true "wasRecentlyCreated" => false "timestamps" => true ] Which of the results, Are the real properties of category class ? I'm confused Edited April 16, 2022 by ali_254 Quote Link to comment Share on other sites More sharing options...
requinix Posted April 16, 2022 Share Posted April 16, 2022 They're both correct. Compare the two. Can you see what's similar between them and what is not? Do you see a pattern to it? The difference is what properties are accessible. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.