-2

I'm working on a project that a register is considered deleted when the column DELETED = 1 and not deleted when the column DELETED is null.

How to make softdelete work on my project so I don't have to manually do it everywhere?

  • 1
    Why just not use a database query to update your tables ? – Vincent Decaux Aug 08 '23 at 13:11
  • You can make your own trait - copy-paste from original trait and edit methods initializeSoftDeletes() and runSoftDelete() to use boolean values – Maksim Aug 08 '23 at 13:31
  • After researching this stuff - i change my mind - this is really hard to make, because you need to overwrite a lot of things. – Maksim Aug 08 '23 at 13:58
  • You would have to create your own `SoftDeletes` trait and `SoftDeletingScope`. You can copy-paste most of the things but you need to change some methods to work with a bool field. – kris gjika Aug 08 '23 at 15:51
  • Did you try `$table->softDeletes($column = 'column_name', $precision = 0);` ? https://laravel.com/docs/10.x/migrations#column-method-softDeletes – Mr. Kenneth Aug 09 '23 at 00:37
  • If you check `SoftDeletes.php > getDeletedAtColumn()`, you can see the defined column or the default `deleted_at` – Mr. Kenneth Aug 09 '23 at 00:38
  • or this package: https://github.com/tenantcloud/laravel-boolean-softdeletes – Mr. Kenneth Aug 09 '23 at 00:47
  • Thanks @krisgjika that's exactly what I did, it's not so hard after all just extend and overwrite, just needed to know how to extend (or sort of) a Trait and it was all good. Lol my question was legit and I got -2 score, this is ridiculous...and Stackoverflow wonder why it's audience is going down... – guilherme.souza Aug 12 '23 at 19:16

0 Answers0