Add licenses table

This commit is contained in:
David Bomba 2021-04-07 00:00:24 +10:00
parent aac6831d15
commit 23206d7a67
2 changed files with 73 additions and 0 deletions

View File

@ -136,4 +136,37 @@ class Ninja
return $translations;
}
public function createLicense($request)
{
// $affiliate = Affiliate::where('affiliate_key', '=', SELF_HOST_AFFILIATE_KEY)->first();
// $email = trim(Input::get('email'));
// if (! $email || $email == TEST_USERNAME) {
// return RESULT_FAILURE;
// }
// $license = new License();
// $license->first_name = Input::get('first_name');
// $license->last_name = Input::get('last_name');
// $license->email = $email;
// $license->transaction_reference = Request::getClientIp();
// $license->license_key = self::generateLicense();
// $license->affiliate_id = $affiliate->id;
// $license->product_id = PRODUCT_SELF_HOST;
// $license->is_claimed = 1;
// $license->save();
// return RESULT_SUCCESS;
}
// public static function generateLicense()
// {
// $parts = [];
// for ($i = 0; $i < 5; $i++) {
// $parts[] = strtoupper(str_random(4));
// }
// return implode('-', $parts);
// }
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLicensesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('licenses', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->string('email')->nullable();
$table->string('license_key')->unique()->nullable();
$table->boolean('is_claimed')->nullable();
$table->string('transaction_reference')->nullable();
$table->unsignedInteger('product_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('licenses');
}
}