Askedio / laravel-soft-cascade

Cascade Delete & Restore when using Laravel SoftDeletes
https://medium.com/asked-io/cascading-softdeletes-with-laravel-5-a1a9335a5b4d
MIT License
705 stars 63 forks source link

MorphMany failure #148

Open jmverges opened 5 months ago

jmverges commented 5 months ago

Description:

I'm using a polymorphic

    public function files(): MorphMany
    {
        return $this->morphMany(File::class, 'files', 'fileable_type', 'fileable_id');
    }

but it seems not to work.

It says

Column not found: 1054 Unknown column 'entry.deleted_at' in 'field list' (SQL: update `files` set `entry`.`deleted_at` = 2024-05-03 14:31:15, `files`.`updated_at` = 2024-05-03 14:31:15 where `id` in (1998334, 1998335, 1998336, 1998337, 1998338, 1998339, 1998340, 1998341, 1998342, 1998343, 1998344, 1998345, 1998346, 1998347, 1998348, 1998349, 1998350, 1998351, 1998352, 1998353, 1998354, 1998355, 1998357, 1998358, 1998359, 1998360, 1998474, 1998475, 1998669, 1998670) limit 30)", message: "Internal server error", extensions: { category: "internal" }, locations: [[Object]], path: ["doEntry"], trace: [[Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], [Object], ... 75 more items] }

Entry is the model that includes the trait and Files is the model that needs to be deleted on cascade

I'm seeing this issues here and seems the same

https://github.com/Askedio/laravel-soft-cascade/issues/109 https://github.com/Askedio/laravel-soft-cascade/issues/31

Any help here?

jmverges commented 5 months ago

@gcphost @maguilar92 any feedback?

jmverges commented 5 months ago

I have a $model->myRelation()->delete() model in myRelation() is the one with softcascade with files table update my_relation.deleted_at="2023-05-15 12:00:00" not found in files Somehow it wants to update set my_relation.deleted_at instead of files.deleted_at