Update user controller
This commit is contained in:
parent
f292080483
commit
e91362eee6
9 changed files with 200 additions and 77 deletions
50
database/migrations/2017_01_12_135449_add_more_user_data.php
Normal file
50
database/migrations/2017_01_12_135449_add_more_user_data.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddMoreUserData extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('name_first')->after('email')->nullable();
|
||||
$table->string('name_last')->after('name_first')->nullable();
|
||||
$table->string('username')->after('uuid');
|
||||
$table->boolean('gravatar')->after('totp_secret')->default(true);
|
||||
});
|
||||
|
||||
DB::transaction(function () {
|
||||
foreach(User::all() as &$user) {
|
||||
$user->username = $user->email;
|
||||
$user->save();
|
||||
}
|
||||
});
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('username')->unique()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('name_first');
|
||||
$table->dropColumn('name_last');
|
||||
$table->dropColumn('username');
|
||||
$table->dropColumn('gravatar');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue