ptgen api point support parameter & default user

This commit is contained in:
xiaomlove
2022-02-28 23:20:42 +08:00
parent 5ed80ed637
commit b9d5df232b
51 changed files with 447 additions and 51 deletions

View File

@@ -3,6 +3,7 @@ namespace App\Repositories;
use App\Http\Resources\UserResource;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\UnauthorizedException;
@@ -22,7 +23,7 @@ class AuthenticateRepository extends BaseRepository
$user->checkIsNormal();
$tokenName = __METHOD__ . __LINE__;
$token = DB::transaction(function () use ($user, $tokenName) {
$user->tokens()->delete();
$user->update(['last_login' => Carbon::now()]);
$tokenResult = $user->createToken($tokenName);
return $tokenResult->plainTextToken;
});