Add api stuff

This commit is contained in:
Russ Long
2019-10-29 15:22:32 -04:00
parent 0f9d04c7e3
commit 9bd968f2d9
16 changed files with 1179 additions and 1 deletions

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateApiKeysTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('api_keys', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('key', 64);
$table->boolean('active')->default(1);
$table->timestamps();
$table->softDeletes();
$table->index('name');
$table->index('key');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('api_keys');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateApiKeyAccessEventsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('api_key_access_events', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('api_key_id');
$table->ipAddress('ip_address');
$table->text('url');
$table->timestamps();
$table->index('ip_address');
$table->foreign('api_key_id')->references('id')->on('api_keys');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('api_key_access_events');
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateApiKeyAdminEventsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('api_key_admin_events', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('api_key_id');
$table->ipAddress('ip_address');
$table->string('event');
$table->timestamps();
$table->index('ip_address');
$table->index('event');
$table->foreign('api_key_id')->references('id')->on('api_keys');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('api_key_admin_events');
}
}