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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)