Closed MatheusAMFB closed 5 years ago
Laravel doesn't support SoftDeletes
on pivot tables: #14008 #20307
You can try this package: https://github.com/mlezcano1985/laravel-pivot-soft-deletes
Also please see the note about this at the end of https://laravel.com/docs/5.8/eloquent-relationships#defining-custom-intermediate-table-models
Description:
In my system there is a 'channels' and 'channelables' table they have a 'MorphToMany' relation. Channels does not have softdelete since it is not possible to delete. Channelable can be deleted with softDeletes. What happens is that when some channelable is deleted the relationship remains intact.
Channable trait /**
@return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function channelables(): MorphMany { return $this->morphMany(\App\Models\Channelable::class, 'channelable'); }
public function channels(): MorphToMany { return $this->morphToMany(Channel::class, 'channelable'); }
Where the relation was to be deleted
And in the table the column 'deleted_at' is filled in properly with the date. But when I use anything involving this relation, it's as if nothing has been deleted.