diff --git a/app/Utils/Ninja.php b/app/Utils/Ninja.php index d9220e15fa93..e5b55d90b9cd 100644 --- a/app/Utils/Ninja.php +++ b/app/Utils/Ninja.php @@ -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); + // } } diff --git a/database/migrations/2021_04_06_131028_create_licenses_table.php b/database/migrations/2021_04_06_131028_create_licenses_table.php new file mode 100644 index 000000000000..40ee64f047ab --- /dev/null +++ b/database/migrations/2021_04_06_131028_create_licenses_table.php @@ -0,0 +1,40 @@ +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'); + } +}