Updating the Relation Model

Submitted by monaye - 1 year ago

There is easy way to update relation model without query for related model.

$shop = Shop::find(1); 

// update shop info 
$shop->fill(['name'=>'product 1']); 
$shop->save(); 

// Update relation model 
$shop->shiping()->update(['normal'=>'1000']); 

comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks