"Laravel flattale" package to let to easily manage de-normalized tables.

Submitted by tkeer - 3 years ago

Laravel package to let you manage de-normalized tables with simple configurations. Just add array based config in your models and it will automatically sync your denormalized tables. https://github.com/tkeer/flattable

// saving books in books' de-normalized tables
// and much more other options

public function getFlattableConfig(): array
{
  [
    [

      'columns' => [

        //flattable column => 'source model column'
        'name' => 'name',
        'published_at' => 'published_at',
        'publisher_id' => 'publisher_id',
        'book_id' => 'id'

      ],

      // type of relationship b/w flattable and model
      'type' => 'primary',

      // how to find related entry in the flattable table
      'wheres' => [

        // key is flattable column
        // value is column of source table (book)
        'book_id' => 'id',

      ],

      'flattable' => 'books_flattable',
    ]
  ]
}