I found this from laracasts and found it useful for me.
Let me paste the answer here:
So I have two models - User and Property User.php
public function properties()
{
return $this->hasMany('App\Models\Property');
}
Property.php
public function user()
{
return $this->belongsTo('App\User');
}
Thus, if I want to delete a particular user, and of course, I don't want any his properties to be retained in the database:
public function destroy($id)
{
$user = User::findOrFail($id);
$user->properties()->delete();
$user->delete();
return [
'message' => 'Delete Complete!'
];
}
I hope you or anyone else finds this useful! Regards :)
Source: https://laracasts.com/discuss/channels/eloquent/laravel-delete-model-with-all-relations