Skip to content

Instantly share code, notes, and snippets.

View zahidmuhammadzaki's full-sized avatar
👽
Zrrrt!

Zahid zahidmuhammadzaki

👽
Zrrrt!
  • Profesi.io
  • Jakarta, Indonesia
View GitHub Profile
@zahidmuhammadzaki
zahidmuhammadzaki / AdonisJs - SoftDelete.js
Last active June 5, 2020 07:45 — forked from andresilvagomez/SoftDeletes.js
Soft delete trait for Adonis 4.
// $ adonis make:trait SoftDelete
class SoftDelete {
register (Model, customOptions = {}) {
const deletedAtColumn = customOptions.name || `${Model.table}.deleted_at`;
Model.addGlobalScope(builder => {
builder.whereNull(deletedAtColumn);
}, 'soft_delete');