From d8dec72cbccbcf540bbea5c0356a80df5a96c071 Mon Sep 17 00:00:00 2001 From: Victor Lap Date: Sun, 12 Feb 2017 18:53:50 +0100 Subject: [PATCH] Add migration --- migrations/create_approvals_table.php.stub | 38 ++++++++++++++++++++++ src/ApprovableServiceProvider.php | 26 +++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 migrations/create_approvals_table.php.stub create mode 100644 src/ApprovableServiceProvider.php diff --git a/migrations/create_approvals_table.php.stub b/migrations/create_approvals_table.php.stub new file mode 100644 index 0000000..a1c3a7e --- /dev/null +++ b/migrations/create_approvals_table.php.stub @@ -0,0 +1,38 @@ +increments('id'); + $table->string('approvable_type'); + $table->integer('approvable_id'); + $table->integer('user_id')->nullable(); + $table->string('key'); + $table->text('value')->nullable(); + $table->boolean('approved')->default(false); + $table->timestamps(); + $table->index(array('approvable_id', 'approvable_type')); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('approvals'); + } +} diff --git a/src/ApprovableServiceProvider.php b/src/ApprovableServiceProvider.php new file mode 100644 index 0000000..bdf333a --- /dev/null +++ b/src/ApprovableServiceProvider.php @@ -0,0 +1,26 @@ +publishes([ + __DIR__ . '/../migrations/create_approvals_table.php.stub' + => database_path("/migrations/{$timestamp}_create_approvals_table.php"), + ], 'migrations'); + } + } +}