Skip to content

Commit

Permalink
modified enabled column
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jun 30, 2018
1 parent 375718b commit 0c579d0
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
30 changes: 30 additions & 0 deletions app/Listeners/Updates/Version1210.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Listeners\Updates;

use App\Events\UpdateFinished;
use Artisan;

class Version1210 extends Listener
{
const ALIAS = 'core';

const VERSION = '1.2.10';

/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
{
// Check if should listen
if (!$this->check($event)) {
return;
}

// Update database
Artisan::call('migrate', ['--force' => true]);
}
}
13 changes: 12 additions & 1 deletion app/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function scopeCollect($query, $sort = 'name')
}

/**
* Scope to only include active currencies.
* Scope to only include active models.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
Expand All @@ -104,4 +104,15 @@ public function scopeEnabled($query)
{
return $query->where('enabled', 1);
}

/**
* Scope to only include passive models.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeDisabled($query)
{
return $query->where('enabled', 0);
}
}
49 changes: 49 additions & 0 deletions database/migrations/2018_06_30_000000_modify_enabled_column.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

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

class ModifyEnabledColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function (Blueprint $table) {
$table->tinyInteger('enabled')->default(1)->change();
});

Schema::table('categories', function (Blueprint $table) {
$table->tinyInteger('enabled')->default(1)->change();
});

Schema::table('currencies', function (Blueprint $table) {
$table->tinyInteger('enabled')->default(1)->change();
});

Schema::table('items', function (Blueprint $table) {
$table->tinyInteger('enabled')->default(1)->change();
});

Schema::table('customers', function (Blueprint $table) {
$table->tinyInteger('enabled')->default(1)->change();
});

Schema::table('vendors', function (Blueprint $table) {
$table->tinyInteger('enabled')->default(1)->change();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{

}
}

0 comments on commit 0c579d0

Please sign in to comment.