frontend/backend update

This commit is contained in:
carodej
2020-06-05 16:48:11 +02:00
parent ca14838212
commit cffdc3ced9
67 changed files with 3611 additions and 1136 deletions
@@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePlansTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('plans', function (Blueprint $table) {
$table->bigIncrements('id');
$table->boolean('status')->default(1);
$table->text('name');
$table->text('price');
$table->integer('capacity');
$table->longText('description')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('plans');
}
}
@@ -25,7 +25,6 @@ class CreateInvoicesTable extends Migration
$table->longText('notes')->nullable();
$table->text('total');
$table->text('currency');
$table->text('path');
$table->timestamps();
});
}
@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePlansTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create(config('rinvex.subscriptions.tables.plans'), function (Blueprint $table) {
// Columns
$table->increments('id');
$table->string('slug');
$table->{$this->jsonable()}('name');
$table->{$this->jsonable()}('description')->nullable();
$table->boolean('is_active')->default(true);
$table->decimal('price')->default('0.00');
$table->decimal('signup_fee')->default('0.00');
$table->string('currency', 3);
$table->smallInteger('trial_period')->unsigned()->default(0);
$table->string('trial_interval')->default('day');
$table->smallInteger('invoice_period')->unsigned()->default(0);
$table->string('invoice_interval')->default('month');
$table->smallInteger('grace_period')->unsigned()->default(0);
$table->string('grace_interval')->default('day');
$table->tinyInteger('prorate_day')->unsigned()->nullable();
$table->tinyInteger('prorate_period')->unsigned()->nullable();
$table->tinyInteger('prorate_extend_due')->unsigned()->nullable();
$table->smallInteger('active_subscribers_limit')->unsigned()->nullable();
$table->mediumInteger('sort_order')->unsigned()->default(0);
$table->timestamps();
$table->softDeletes();
// Indexes
$table->unique('slug');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists(config('rinvex.subscriptions.tables.plans'));
}
/**
* Get jsonable column data type.
*
* @return string
*/
protected function jsonable(): string
{
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
}
}
@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePlanFeaturesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create(config('rinvex.subscriptions.tables.plan_features'), function (Blueprint $table) {
// Columns
$table->increments('id');
$table->integer('plan_id')->unsigned();
$table->string('slug');
$table->{$this->jsonable()}('name');
$table->{$this->jsonable()}('description')->nullable();
$table->string('value');
$table->smallInteger('resettable_period')->unsigned()->default(0);
$table->string('resettable_interval')->default('month');
$table->mediumInteger('sort_order')->unsigned()->default(0);
$table->timestamps();
$table->softDeletes();
// Indexes
$table->unique(['plan_id', 'slug']);
$table->foreign('plan_id')->references('id')->on(config('rinvex.subscriptions.tables.plans'))
->onDelete('cascade')->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_features'));
}
/**
* Get jsonable column data type.
*
* @return string
*/
protected function jsonable(): string
{
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
}
}
@@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePlanSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create(config('rinvex.subscriptions.tables.plan_subscriptions'), function (Blueprint $table) {
$table->increments('id');
$table->morphs('user');
$table->integer('plan_id')->unsigned();
$table->string('slug');
$table->{$this->jsonable()}('name');
$table->{$this->jsonable()}('description')->nullable();
$table->dateTime('trial_ends_at')->nullable();
$table->dateTime('starts_at')->nullable();
$table->dateTime('ends_at')->nullable();
$table->dateTime('cancels_at')->nullable();
$table->dateTime('canceled_at')->nullable();
$table->string('timezone')->nullable();
$table->timestamps();
$table->softDeletes();
// Indexes
$table->unique('slug');
$table->foreign('plan_id')->references('id')->on(config('rinvex.subscriptions.tables.plans'))
->onDelete('cascade')->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscriptions'));
}
/**
* Get jsonable column data type.
*
* @return string
*/
protected function jsonable(): string
{
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
}
}
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePlanSubscriptionUsageTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create(config('rinvex.subscriptions.tables.plan_subscription_usage'), function (Blueprint $table) {
$table->increments('id');
$table->integer('subscription_id')->unsigned();
$table->integer('feature_id')->unsigned();
$table->smallInteger('used')->unsigned();
$table->dateTime('valid_until')->nullable();
$table->string('timezone')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['subscription_id', 'feature_id']);
$table->foreign('subscription_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_subscriptions'))
->onDelete('cascade')->onUpdate('cascade');
$table->foreign('feature_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_features'))
->onDelete('cascade')->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscription_usage'));
}
}