Unset/Remove relation object from Laravel Eloquent collection

In Laravel 5.6.25, you can use unsetRelation():

$product->unsetRelation('merchant')->unsetRelation('picture');

Before that:

$relations = $product->getRelations();
unset($relations['merchant'], $relations['picture']);
$product->setRelations($relations);

Leave a Comment