diff --git a/app/Http/Controllers/Install/Updates.php b/app/Http/Controllers/Install/Updates.php index 9a35c0b09..72cc61546 100644 --- a/app/Http/Controllers/Install/Updates.php +++ b/app/Http/Controllers/Install/Updates.php @@ -111,9 +111,6 @@ class Updates extends Controller // Clear cache after update Artisan::call('cache:clear'); - // Update database - Artisan::call('migrate', ['--force' => true]); - event(new UpdateFinished($alias, $old, $new)); flash(trans('updates.success'))->success(); diff --git a/app/Listeners/Updates/Version113.php b/app/Listeners/Updates/Version113.php index ec04aeeb4..d6955bd51 100644 --- a/app/Listeners/Updates/Version113.php +++ b/app/Listeners/Updates/Version113.php @@ -37,5 +37,7 @@ class Version113 extends Listener $currency->save(); } + // Update database + Artisan::call('migrate', ['--force' => true]); } } diff --git a/app/Listeners/Updates/Version116.php b/app/Listeners/Updates/Version117.php similarity index 50% rename from app/Listeners/Updates/Version116.php rename to app/Listeners/Updates/Version117.php index 7fa0afead..5a1bff775 100644 --- a/app/Listeners/Updates/Version116.php +++ b/app/Listeners/Updates/Version117.php @@ -5,11 +5,14 @@ namespace App\Listeners\Updates; use App\Events\UpdateFinished; use App\Models\Setting\Currency; -class Version116 extends Listener +use Illuminate\Support\Facades\Schema; +use Illuminate\Database\Schema\Blueprint; + +class Version117 extends Listener { const ALIAS = 'core'; - const VERSION = '1.1.6'; + const VERSION = '1.1.7'; /** * Handle the event. @@ -24,6 +27,37 @@ class Version116 extends Listener return; } + Schema::create('media', function (Blueprint $table) { + $table->increments('id'); + $table->string('disk', 32); + $table->string('directory'); + $table->string('filename'); + $table->string('extension', 32); + $table->string('mime_type', 128); + $table->string('aggregate_type', 32); + $table->integer('size')->unsigned(); + $table->timestamps(); + $table->softDeletes(); + + $table->index(['disk', 'directory']); + $table->unique(['disk', 'directory', 'filename', 'extension']); + $table->index('aggregate_type'); + }); + + Schema::create('mediables', function (Blueprint $table) { + $table->integer('media_id')->unsigned(); + $table->string('mediable_type'); + $table->integer('mediable_id')->unsigned(); + $table->string('tag'); + $table->integer('order')->unsigned(); + + $table->primary(['media_id', 'mediable_type', 'mediable_id', 'tag']); + $table->index(['mediable_id', 'mediable_type']); + $table->index('tag'); + $table->index('order'); + $table->foreign('media_id')->references('id')->on('media')->onDelete('cascade'); + }); + $migrations = [ '\App\Models\Auth\User' => 'picture', '\App\Models\Item\Item' => 'picture', @@ -52,5 +86,8 @@ class Version116 extends Listener } } } + + // Update database + Artisan::call('migrate', ['--force' => true]); } } diff --git a/app/Models/Auth/User.php b/app/Models/Auth/User.php index 5367d36ff..2f7fce918 100644 --- a/app/Models/Auth/User.php +++ b/app/Models/Auth/User.php @@ -27,7 +27,7 @@ class User extends Authenticatable * * @var array */ - protected $fillable = ['name', 'email', 'password', 'locale', 'picture', 'enabled']; + protected $fillable = ['name', 'email', 'password', 'locale', 'enabled']; /** * The attributes that should be hidden for arrays. diff --git a/app/Models/Expense/Bill.php b/app/Models/Expense/Bill.php index 10d6731bb..c44bdaf64 100644 --- a/app/Models/Expense/Bill.php +++ b/app/Models/Expense/Bill.php @@ -22,7 +22,7 @@ class Bill extends Model * * @var array */ - protected $fillable = ['company_id', 'bill_number', 'order_number', 'bill_status_code', 'billed_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'vendor_name', 'vendor_email', 'vendor_tax_number', 'vendor_phone', 'vendor_address', 'notes', 'attachment']; + protected $fillable = ['company_id', 'bill_number', 'order_number', 'bill_status_code', 'billed_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'vendor_name', 'vendor_email', 'vendor_tax_number', 'vendor_phone', 'vendor_address', 'notes']; /** * Sortable columns. diff --git a/app/Models/Expense/BillPayment.php b/app/Models/Expense/BillPayment.php index e0d0c2702..066d5ed45 100644 --- a/app/Models/Expense/BillPayment.php +++ b/app/Models/Expense/BillPayment.php @@ -20,7 +20,7 @@ class BillPayment extends Model * * @var array */ - protected $fillable = ['company_id', 'bill_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference', 'attachment']; + protected $fillable = ['company_id', 'bill_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference']; public function account() { diff --git a/app/Models/Expense/Payment.php b/app/Models/Expense/Payment.php index c61e8f767..ab50ae53c 100644 --- a/app/Models/Expense/Payment.php +++ b/app/Models/Expense/Payment.php @@ -20,7 +20,7 @@ class Payment extends Model * * @var array */ - protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'description', 'category_id', 'payment_method', 'reference', 'attachment']; + protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'vendor_id', 'description', 'category_id', 'payment_method', 'reference']; /** * Sortable columns. diff --git a/app/Models/Income/Invoice.php b/app/Models/Income/Invoice.php index 7e88969ab..eb4ba2f4d 100644 --- a/app/Models/Income/Invoice.php +++ b/app/Models/Income/Invoice.php @@ -30,7 +30,7 @@ class Invoice extends Model * * @var array */ - protected $fillable = ['company_id', 'invoice_number', 'order_number', 'invoice_status_code', 'invoiced_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'customer_name', 'customer_email', 'customer_tax_number', 'customer_phone', 'customer_address', 'notes', 'attachment']; + protected $fillable = ['company_id', 'invoice_number', 'order_number', 'invoice_status_code', 'invoiced_at', 'due_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'customer_name', 'customer_email', 'customer_tax_number', 'customer_phone', 'customer_address', 'notes']; /** * Sortable columns. diff --git a/app/Models/Income/InvoicePayment.php b/app/Models/Income/InvoicePayment.php index ce59d42a6..f1bb41e2c 100644 --- a/app/Models/Income/InvoicePayment.php +++ b/app/Models/Income/InvoicePayment.php @@ -20,7 +20,7 @@ class InvoicePayment extends Model * * @var array */ - protected $fillable = ['company_id', 'invoice_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference', 'attachment']; + protected $fillable = ['company_id', 'invoice_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'description', 'payment_method', 'reference']; public function account() { diff --git a/app/Models/Income/Revenue.php b/app/Models/Income/Revenue.php index 7a363482d..955154c3b 100644 --- a/app/Models/Income/Revenue.php +++ b/app/Models/Income/Revenue.php @@ -20,7 +20,7 @@ class Revenue extends Model * * @var array */ - protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'description', 'category_id', 'payment_method', 'reference', 'attachment']; + protected $fillable = ['company_id', 'account_id', 'paid_at', 'amount', 'currency_code', 'currency_rate', 'customer_id', 'description', 'category_id', 'payment_method', 'reference']; /** * Sortable columns. diff --git a/app/Models/Item/Item.php b/app/Models/Item/Item.php index c6dec6741..4fa2bdbc7 100644 --- a/app/Models/Item/Item.php +++ b/app/Models/Item/Item.php @@ -19,7 +19,7 @@ class Item extends Model * * @var array */ - protected $fillable = ['company_id', 'name', 'sku', 'description', 'sale_price', 'purchase_price', 'quantity', 'category_id', 'tax_id', 'picture', 'enabled']; + protected $fillable = ['company_id', 'name', 'sku', 'description', 'sale_price', 'purchase_price', 'quantity', 'category_id', 'tax_id', 'enabled']; /** * Sortable columns.