I am making a query in this way. To load all sales with their respective relationships, It turns out that everything is fine.
$ventas = Venta::with(['categoria','user','foto'])
->orderBy('id','DESC')
->where('status','PUBLICADO')
->paginate(10);
but I would like certain fields eg. of user will not be charged as good. When he sent you to a hearing. I only show what is necessary, but how can I prevent it from loading? the "user password" field?
I made a dd
#items: Collection {#546 ▼
#items: array:5 [▶]
And this shows me.
Each sale has its data. And all perfect. but . .
0 => Venta {#452 ▼
#connection: "mysql"
#table: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:9 [▶]
#original: array:9 [▶]
#changes: []
#casts: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: array:3 [▶]
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [▶]
}
these are your relationships.
#relations: array:3 [▼
"categoria" => Categoria {#487 ▶}
"user" => User {#547 ▶}
"foto" => Foto {#645 ▶}
]
but I'm loading the password field :(
"user" => User {#547 ▼
#fillable: array:3 [▶]
#hidden: array:2 [▶]
#connection: "mysql"
#table: null
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:12 [▼
"id" => 3
"nick" => "Taniaħ"
"email" => "[email protected]"
"password" => "$2y$10$BaEUQJdHCmZsqIuf0VGbkOdJmYi32kPx/Ce6Azyu.o.Xajtg9DCSS"
"nombre" => "Tani"
"apellidoP" => null
"apellidoM" => null
"fotoPerfil" => "http://carrefourjeunesse.fr/wp-content/uploads/2017/06/female1-512.png"
"fechaNacimiento" => null
"remember_token" => "QSKRWXcCejTA4Px0kWMhmrK3BMgxiSiAKux7yEp7HDOd8xx9YkUu0YiFtK5X"
"created_at" => "2018-09-12 15:55:57"
"updated_at" => "2018-09-12 15:55:57"
]