Unset/Remove relation object from Laravel Eloquent collection

I have to tables with the same fields.. So I need to check the different column based on value. So if the value of foreign key is same then need to unset that relation

If you have merchant property in the model (merchant column in the table) you can get it value using $product->getOriginal('merchant') or $product->getAttribute('merchant')


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);