Wednesday, April 12, 2017

Returning all collections relational table

Im retrieding all the data related with a specific object, but instead of getting only the data related with the product is getting me all the data from the table.

Controller:

$product = Product::find($id);
return $product->with('detailsProduct')->get();

Model Product:

public function detailsProduct(){
        return $this->hasMany(ProductTranslation::class);
    }



via Pedro

Advertisement