Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlap committed Feb 12, 2017
1 parent 2c8d3ae commit d8dec72
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
38 changes: 38 additions & 0 deletions migrations/create_approvals_table.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateApprovalsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('approvals', function (Blueprint $table) {
$table->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');
}
}
26 changes: 26 additions & 0 deletions src/ApprovableServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Victorlap\Approvable;

use Illuminate\Support\ServiceProvider;

/**
* Class ApprovableServiceProvider
* @package Victorlap\Approvable
*/
class ApprovableServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application events.
*/
public function boot()
{
if (!class_exists('CreateApprovalsTable')) {
$timestamp = date('Y_m_d_His', time());
$this->publishes([
__DIR__ . '/../migrations/create_approvals_table.php.stub'
=> database_path("/migrations/{$timestamp}_create_approvals_table.php"),
], 'migrations');
}
}
}

0 comments on commit d8dec72

Please sign in to comment.