master
cody 3 months ago
parent ac10143ecb
commit 5dea483f6b

@ -75,7 +75,7 @@ class AutoSchoolmate extends Command
->orWhereNull('is_schoolmate');
})
//->where('is_black',0)
->update(['is_schoolmate' => 1]);
->update(['is_schoolmate' => 1, 'schoolmate_time' => now()]);
$totalUpdated += $updated;
}

@ -742,6 +742,7 @@ class UserController extends BaseController
$data = [];
if (isset($all['is_schoolmate'])) {
$data['is_schoolmate'] = $all['is_schoolmate'];
$data['schoolmate_time'] = ($all['is_schoolmate'] == 1) ? now() : null;
}
$this->model->whereIn('id', $idsArray)->update($data);
return $this->success('批量更新成功');
@ -794,6 +795,10 @@ class UserController extends BaseController
return $this->fail([StarterResponseCode::START_ERROR_PARAMETER, '没有可更新的有效字段']);
}
if (array_key_exists('is_schoolmate', $data)) {
$data['schoolmate_time'] = ($data['is_schoolmate'] == 1) ? now() : null;
}
// 解析用户ID
$idsArray = explode(',', $all['ids']);
$idsArray = array_filter(array_map('trim', $idsArray));

@ -125,29 +125,6 @@ class User extends Authenticatable implements Auditable
'is_schoolmate' => ['否', '是'],
];
/**
* Boot 方法 - 处理模型事件
*/
protected static function boot()
{
parent::boot();
static::saving(function ($user) {
// 当 is_schoolmate 被设置为 1 时,自动设置成为校友时间
if ($user->isDirty('is_schoolmate')) {
if ($user->is_schoolmate == 1) {
// 如果是从非校友变成校友,设置成为校友时间为当前时间
if ($user->getOriginal('is_schoolmate') != 1) {
$user->schoolmate_time = now();
}
} elseif ($user->is_schoolmate == 0 || $user->is_schoolmate === null) {
// 如果设置为 0 或 null清空成为校友时间
$user->schoolmate_time = null;
}
}
});
}
public function getMobileAttribute($value)
{
// 如果url中包含admin字符串则所有的手机号显示中间4位星号代替

Loading…
Cancel
Save