next commit

This commit is contained in:
2019-09-26 01:45:12 -05:00
parent e94b153718
commit 89a691af52
22 changed files with 1505 additions and 37 deletions
@@ -13,15 +13,110 @@ class CreateUsersTable extends Migration
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
if(!Schema::hasTable('users')) {
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('character_id')->unsigned()->unique();
$table->string('avatar');
$table->string('access_token')->nullable();
$table->string('refresh_token')->nullable();
$table->integer('inserted_at')->default(0);
$table->integer('expires_in')->default(0);
$table->string('owner_hash');
$table->string('user_type')->default('Guest');
$table->timestamps();
});
}
if(!Schema::hasTable('user_roles')) {
Schema::create('user_roles', function (Blueprint $table) {
$table->increments('id');
$table->integer('character_id')->unsigned();
$table->foreign('character_id')->references('character_id')->on('users');
$table->string('role')->default('None');
$table->timestamps();
});
}
if(!Schema::hasTable('esi_tokens')) {
Schema::create('esi_tokens', function (Blueprint $table) {
$table->increments('id');
$table->integer('character_id')->unique();
$table->foreign('character_id')->references('character_id')->on('users');
$table->string('access_token');
$table->string('refresh_token');
$table->integer('expires_in');
$table->timestamps();
});
}
if(!Schema::hasTable('esi_scopes')) {
Schema::create('esi_scopes', function (Blueprint $table) {
$table->increments('id');
$table->integer('character_id');
$table->foreign('character_id')->references('character_id')->on('users');
$table->string('scope');
$table->timestamps();
});
}
if(!Schema::hasTable('user_permissions')) {
Schema::create('user_permissions', function (Blueprint $table) {
$table->increments('id');
$table->integer('character_id')->unisnged();
$table->foreign('character_id')->references('character_id')->on('users');
$table->string('permission');
$table->timestamps();
});
}
if(!Schema::hasTable('available_user_permissions')) {
Schema::create('available_user_permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('permission');
});
}
if(!Schema::hasTable('available_user_roles')) {
Schema::create('available_user_roles', function (Blueprint $table) {
$table->increments('id');
$table->string('role');
$table->string('description');
$table->timestamps();
});
DB::table('available_user_roles')->insert([
'role' => 'Guest',
'description' => 'Guest of the site.',
]);
DB::table('available_user_roles')->insert([
'role' => 'User',
'description' => 'User with non-admin access.',
]);
DB::table('available_user_roles')->insert([
'role' => 'Admin',
'description' => 'User with admin access.',
]);
DB::table('available_user_roles')->insert([
'role' => 'SuperUser',
'description' => 'SuperUser',
]);
}
if(!Schema::hasTable('allowed_logins')) {
Schema::create('allowed_logins', function (Blueprint $table) {
$table->increments('id');
$table->string('entity_id');
$table->string('entity_type');
$table->string('entity_name');
$table->string('login_type');
$table->timestamps();
});
}
}
/**
@@ -32,5 +127,12 @@ class CreateUsersTable extends Migration
public function down()
{
Schema::dropIfExists('users');
Schema::dropIfExists('user_roles');
Schema::dropIfExists('esi_tokens');
Schema::dropIfExists('esi_scopes');
Schema::dropIfExists('user_permissions');
Schema::dropIfExists('available_user_permissions');
Schema::dropIfExists('available_user_roles');
Schema::dropIfExists('allowed_logins');
}
}
@@ -0,0 +1,79 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class NewLookupTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!Schema::hasTable('character_lookup')) {
Schema::create('character_lookup', function (Blueprint $table) {
$table->unsignedInteger('character_id');
$table->unsignedInteger('alliance_id');
$table->unsignedInteger('ancestry_id')->nullable();
$table->string('birthday');
$table->unsignedInteger('bloodline_id');
$table->unsignedInteger('corporation_id');
$table->string('description')->nullable();
$table->unsignedInteger('faction_id')->nullable();
$table->string('gender');
$table->string('name');
$table->unsignedInteger('race_id');
$table->float('security_status');
$table->string('title');
});
}
if(!Schema::hasTable('corporation_lookup')) {
Schema::create('corporation_lookup', function (Blueprint $table) {
$table->unsignedInteger('corporation_id');
$table->unsignedInteger('alliance_id')->nullable();
$table->unsignedInteger('ceo_id');
$table->unsignedInteger('creator_id');
$table->string('date_founded')->nullable();
$table->string('description')->nullable();
$table->unsignedInteger('faction_id')->nullable();
$table->unsignedInteger('home_station_id')->nullable();
$table->unsignedInteger('member_count');
$table->string('name');
$table->unsignedInteger('shares')->nullable();
$table->decimal('tax_rate', 20, 2);
$table->string('ticker');
$table->string('url')->nullable();
$table->boolean('war_eligible');
});
}
if(!Schema::hasTable('alliance_lookup')) {
Schema::create('alliance_lookup', function (Blueprint $table) {
$table->unsignedInteger('alliance_id');
$table->unsignedInteger('creator_corporation_id');
$table->unsignedInteger('creator_id');
$table->dateTime('date_founded');
$table->unsignedInteger('executor_corporation_id')->nullable();
$table->unsignedInteger('faction_id')->nullable();
$table->string('name');
$table->string('ticker');
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('character_lookup');
Schema::dropIfExists('corporation_lookup');
Schema::dropIfExists('alliance_lookup');
}
}
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
class CreateSolarSystemsTable extends Migration
{
/**
* Run the migrations.
@@ -13,11 +13,12 @@ class CreatePasswordResetsTable extends Migration
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
if(!Schema::hasTable('solar_systems')) {
Schema::create('solar_systems', function (Blueprint $table) {
$table->string('name');
$table->string('solar_system_id')->unique();
});
}
}
/**
@@ -27,6 +28,6 @@ class CreatePasswordResetsTable extends Migration
*/
public function down()
{
Schema::dropIfExists('password_resets');
Schema::dropIfExists('solar_systems');
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Seeder;
use App\Models\Lookups\SolarSystem;
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
class SolarSystemSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$configuration = Configuration::getInstance();
$configuration->cache = NullCache::class;
$esi = new Eseye();
$systems = $esi->invoke('get', '/universe/systems/');
foreach($systems as $system) {
try {
$info = $esi->invoke('get', '/universe/systems/{system_id}/', [
'system_id' => $system,
]);
} catch(RequestFailedException $e) {
}
$count = SolarSystem::where(['system_id' => $system])->count();
if($count == 0) {
SolarSystem::insert([
'name' => $info->name,
'solar_system_id' => $system,
]);
}
}
}
}