WIP: Standard backend theme page and login

Signed-off-by: Deon George <deon@leenooks.net>
This commit is contained in:
Deon George
2017-12-12 16:28:49 +11:00
parent e594ff2057
commit 33658e37a3
45 changed files with 1150 additions and 896 deletions

View File

@@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePerformanceIndicatorsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('performance_indicators', function (Blueprint $table) {
$table->increments('id');
$table->decimal('monthly_recurring_revenue');
$table->decimal('yearly_recurring_revenue');
$table->decimal('daily_volume');
$table->integer('new_users');
$table->timestamps();
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('performance_indicators');
}
}

View File

@@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAnnouncementsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('announcements', function (Blueprint $table) {
$table->string('id')->primary();
$table->integer('user_id');
$table->text('body');
$table->string('action_text')->nullable();
$table->text('action_url')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('announcements');
}
}

View File

@@ -1,56 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->text('photo_url')->nullable();
$table->tinyInteger('uses_two_factor_auth')->default(0);
$table->string('authy_id')->nullable();
$table->string('country_code', 10)->nullable();
$table->string('phone', 25)->nullable();
$table->string('two_factor_reset_code', 100)->nullable();
$table->integer('current_team_id')->nullable();
$table->string('stripe_id')->nullable();
$table->string('current_billing_plan')->nullable();
$table->string('card_brand')->nullable();
$table->string('card_last_four')->nullable();
$table->string('card_country')->nullable();
$table->string('billing_address')->nullable();
$table->string('billing_address_line_2')->nullable();
$table->string('billing_city')->nullable();
$table->string('billing_state')->nullable();
$table->string('billing_zip', 25)->nullable();
$table->string('billing_country', 2)->nullable();
$table->string('vat_id', 50)->nullable();
$table->text('extra_billing_information')->nullable();
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('last_read_announcements_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}

View File

@@ -1,31 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('password_resets');
}
}

View File

@@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateApiTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('api_tokens', function (Blueprint $table) {
$table->string('id')->primary();
$table->integer('user_id');
$table->string('name');
$table->string('token', 100)->unique();
$table->text('metadata');
$table->tinyInteger('transient')->default(0);
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'expires_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('api_tokens');
}
}

View File

@@ -1,50 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subscriptions', function ($table) {
$table->increments('id');
$table->integer('user_id');
$table->string('name');
$table->string('stripe_id');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
Schema::create('team_subscriptions', function ($table) {
$table->increments('id');
$table->integer('team_id');
$table->string('name');
$table->string('stripe_id');
$table->string('stripe_plan');
$table->integer('quantity');
$table->timestamp('trial_ends_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('subscriptions');
Schema::drop('team_subscriptions');
}
}

View File

@@ -1,42 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateInvoicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoices', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->nullable()->index();
$table->integer('team_id')->nullable()->index();
$table->string('provider_id');
$table->decimal('total')->nullable();
$table->decimal('tax')->nullable();
$table->string('card_country')->nullable();
$table->string('billing_state')->nullable();
$table->string('billing_zip')->nullable();
$table->string('billing_country')->nullable();
$table->string('vat_id', 50)->nullable();
$table->timestamps();
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('invoices');
}
}

View File

@@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->string('id')->primary();
$table->integer('user_id');
$table->integer('created_by')->nullable();
$table->string('icon', 50)->nullable();
$table->text('body');
$table->string('action_text')->nullable();
$table->text('action_url')->nullable();
$table->tinyInteger('read')->default(0);
$table->timestamps();
$table->index(['user_id', 'created_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('notifications');
}
}

View File

@@ -1,48 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTeamsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('teams', function (Blueprint $table) {
$table->increments('id');
$table->integer('owner_id')->index();
$table->string('name');
$table->string('slug')->nullable()->unique();
$table->text('photo_url')->nullable();
$table->string('stripe_id')->nullable();
$table->string('current_billing_plan')->nullable();
$table->string('card_brand')->nullable();
$table->string('card_last_four')->nullable();
$table->string('card_country')->nullable();
$table->string('billing_address')->nullable();
$table->string('billing_address_line_2')->nullable();
$table->string('billing_city')->nullable();
$table->string('billing_state')->nullable();
$table->string('billing_zip', 25)->nullable();
$table->string('billing_country', 2)->nullable();
$table->string('vat_id', 50)->nullable();
$table->text('extra_billing_information')->nullable();
$table->timestamp('trial_ends_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('teams');
}
}

View File

@@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTeamUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('team_users', function (Blueprint $table) {
$table->integer('team_id');
$table->integer('user_id');
$table->string('role', 20);
$table->unique(['team_id', 'user_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('team_users');
}
}

View File

@@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateInvitationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invitations', function (Blueprint $table) {
$table->string('id')->primary();
$table->integer('team_id')->index();
$table->integer('user_id')->nullable()->index();
$table->string('email');
$table->string('token', 40)->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('invitations');
}
}

View File

@@ -5,7 +5,7 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\Site;
class CreateTableSite extends Migration
class CreateTableSites extends Migration
{
private $convert = 'App\Models\Old\Setup';
@@ -16,8 +16,8 @@ class CreateTableSite extends Migration
*/
public function up()
{
Schema::dropIfExists('site');
Schema::create('site', function (Blueprint $table) {
Schema::dropIfExists('sites');
Schema::create('sites', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('url');
@@ -37,20 +37,16 @@ class CreateTableSite extends Migration
if ($this->convert)
foreach (($this->convert)::all() as $o)
{
$so = Site::where(['url'=>rtrim($o->url,'/')])->first();
if (! $so)
$so = new Site;
$so->url = rtrim($o->url,'/');
$so->name = $o->site_details['name'];
$so->email = $o->site_details['email'];
$so->address = ['address1'=>$o->site_details['address1'],'address2'=>$o->site_details['address2'],'city'=>$o->site_details['city'],'state'=>$o->site_details['state'],'postcode'=>$o->site_details['pcode']];
$so->phone = $o->site_details['phone'];
$so->fax = $o->site_details['fax'];
$so->theme = 'metronic-fe';
$so->devurl = 'http://graytech';
$so->save();
$oo = new Site;
$oo->url = rtrim($o->url,'/');
$oo->name = $o->site_details['name'];
$oo->email = $o->site_details['email'];
$oo->address = ['address1'=>$o->site_details['address1'],'address2'=>$o->site_details['address2'],'city'=>$o->site_details['city'],'state'=>$o->site_details['state'],'postcode'=>$o->site_details['pcode']];
$oo->phone = $o->site_details['phone'];
$oo->fax = $o->site_details['fax'];
$oo->theme = 'metronic-fe';
$oo->devurl = 'http://graytech';
$oo->save();
}
}
@@ -61,6 +57,6 @@ class CreateTableSite extends Migration
*/
public function down()
{
Schema::dropIfExists('site');
Schema::dropIfExists('sites');
}
}
}

View File

@@ -0,0 +1,49 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\Currency;
class CreateTableCurrencies extends Migration
{
private $convert = 'App\Models\Old\Currency';
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('currencies');
Schema::create('currencies', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('symbol',2)->nullable();
$table->string('threecode',3);
$table->boolean('active');
});
if ($this->convert)
foreach (($this->convert)::all() as $o)
{
$oo = new Currency;
$oo->name = $o->name;
$oo->symbol = $o->symbol;
$oo->threecode = $o->three_digit;
$oo->active = $o->three_code == 'AUS' ? TRUE : FALSE;
$oo->save();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('currencies');
}
}

View File

@@ -0,0 +1,59 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\{Country,Currency};
class CreateTableCountries extends Migration
{
private $convert = 'App\Models\Old\Country';
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('countries');
Schema::create('countries', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('twocode',2)->nullable();
$table->string('threecode',3);
$table->integer('currency_id')->unsigned()->nullable();
$table->boolean('active');
$table->foreign('currency_id')->references('id')->on('currencies');
});
if ($this->convert)
foreach (($this->convert)::all() as $o)
{
if ($o->currency)
$co = Currency::where('name',$o->currency->name)->firstOrFail();
$oo = new Country;
$oo->name = $o->name;
$oo->twocode = $o->two_code;
$oo->threecode = $o->three_code;
$oo->active = $o->three_code == 'AUS' ? TRUE : FALSE;
if ($o->currency)
$co->countries()->save($oo);
else
$oo->save();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('countries');
}
}

View File

@@ -0,0 +1,86 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\Country;
use App\User;
class CreateTableUsers extends Migration
{
private $convert = 'App\Models\Old\Account';
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('users');
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('site_id');
$table->string('email');
$table->string('password')->nullable();
$table->rememberToken();
$table->boolean('active');
$table->string('title')->nullable();
$table->string('firstname');
$table->string('lastname');
$table->integer('country_id');
$table->string('address1')->nullable();
$table->string('address2')->nullable();
$table->string('city')->nullable();
$table->string('state')->nullable();
$table->string('postcode')->nullable();
$table->boolean('emailable')->default(TRUE);
$table->unique(['site_id','email']);
});
if ($this->convert)
foreach (($this->convert)::where('id','>',0)->get() as $o)
{
$co = Country::where('name',$o->country->name)->firstOrFail();
$oo = User::where('email',$o->email)->first();
if ($oo) {
if ($oo->updated_at > date('Y-m-d H:i:s',$o->date_last))
continue;
//printf("Updating user [%s]\n",$oo->email);
} else {
$oo = new User;
//printf("New user [%s]\n",$o->email);
}
$oo->site_id = $o->site_id;
$oo->email = $o->email;
$oo->password = $o->password;
$oo->firstname = $o->first_name;
$oo->lastname = $o->last_name;
$oo->address1 = $o->address1;
$oo->address2 = $o->address2;
$oo->city = $o->city;
$oo->state = $o->state;
$oo->postcode = $o->zip;
$oo->active = $o->active;
$oo->created_at = date('Y-m-d H:i:s',$o->date_orig);
$oo->updated_at = $o->date_last ? date('Y-m-d H:i:s',$o->date_last) : NULL;
//$oo->country_id = $co->id;
$co->users()->save($oo);
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}