真实邀请人ID
parent
5a94d3c686
commit
75d98b5f71
|
|
@ -61,6 +61,21 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
|
||||||
'status' => 'int',
|
'status' => 'int',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected static function booted()
|
||||||
|
{
|
||||||
|
parent::created(function ($user) {
|
||||||
|
//初始化钱包
|
||||||
|
$user->wallet()->create();
|
||||||
|
//初始化余额
|
||||||
|
$user->balance()->create();
|
||||||
|
//初始化经销商信息
|
||||||
|
$user->dealer()->create();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属于此用户的个人信息
|
* 属于此用户的个人信息
|
||||||
*
|
*
|
||||||
|
|
@ -379,6 +394,10 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
|
||||||
{
|
{
|
||||||
$user = static::query()->create($attributes);
|
$user = static::query()->create($attributes);
|
||||||
|
|
||||||
|
if ($inviter === null) {
|
||||||
|
$inviter = static::find(1);
|
||||||
|
}
|
||||||
|
|
||||||
// 邀请人的深度
|
// 邀请人的深度
|
||||||
$depth = (int) $inviter?->userInfo?->depth;
|
$depth = (int) $inviter?->userInfo?->depth;
|
||||||
|
|
||||||
|
|
@ -386,15 +405,9 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
|
||||||
'inviter_id' => $inviter?->id,
|
'inviter_id' => $inviter?->id,
|
||||||
'depth' => $depth + 1,
|
'depth' => $depth + 1,
|
||||||
'path' => Str::finish($inviter?->userInfo?->full_path, '-'),
|
'path' => Str::finish($inviter?->userInfo?->full_path, '-'),
|
||||||
|
'real_inviter_id' => $inviter?->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//初始化钱包
|
|
||||||
$user->wallet()->create();
|
|
||||||
//初始化余额
|
|
||||||
$user->balance()->create();
|
|
||||||
//初始化经销商信息
|
|
||||||
$user->dealer()->create();
|
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ class UserInfo extends Model
|
||||||
'growth_value',
|
'growth_value',
|
||||||
'pre_growth_value',
|
'pre_growth_value',
|
||||||
'group_sales_value',
|
'group_sales_value',
|
||||||
|
'real_inviter_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddRealInviterIdToUserInfosTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('user_infos', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('real_inviter_id')->nullable()->comment('真实邀请人ID');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('user_infos', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('real_inviter_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue