modified enabled column

This commit is contained in:
denisdulici 2018-06-30 12:37:19 +03:00
parent 375718b5d0
commit 0c579d02b0
3 changed files with 91 additions and 1 deletions

View File

@ -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]);
}
}

View File

@ -95,7 +95,7 @@ class Model extends Eloquent
}
/**
* Scope to only include active currencies.
* Scope to only include active models.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
@ -104,4 +104,15 @@ class Model extends Eloquent
{
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);
}
}

View File

@ -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()
{
}
}