Commit 7257dc2e by 杨树贤

新增用户添加编码

parent ba2c5366
<?php
namespace App\Http\Services;
use App\Models\CountryModel;
use App\Models\UserModel;
use Carbon\Carbon;
use Illuminate\Support\Facades\Redis;
class UserService
{
public static function generateSn()
{
$maxInquiryId = UserModel::orderBy('id', 'desc')->value('id');
$id = str_pad(($maxInquiryId + 1), 6, 0, STR_PAD_LEFT);
$time = Carbon::now()->addMonths(-9)->addDays(-10)->timestamp;
return date('Ymd',$time) . $id;
}
}
......@@ -2,6 +2,7 @@
namespace App\Models;
use App\Http\Services\UserService;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
......@@ -49,6 +50,7 @@ class UserModel extends Authenticatable implements MustVerifyEmail
'phone' => $data['phone'],
'email_verified_at' => now(),
'company_name' => $data['company_name'],
'user_sn' => UserService::generateSn(),
'account_properties' => $data['account_properties'],
'password' => Hash::make($data['password']),
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment