I'm doing the following query.
$Products = Product::with('productFiles')->where("name", "like", "%{$request->value}%")->limit(10)->get();
This query calls all the products and an array called "productFiles" WITH DATA. But if I add a select as the following, the array "productFiles" is empty.
$Products = Product::select('name', 'slug')->with('productFiles')->where("name", "like", "%{$request->value}%")->limit(10)->get();
I must clarify that productFiles is a method of the Product model, it is declared like this.
public function productFiles(){
return $this->hasMany(ProductFile::class);
}
Thanks for your help!