generated from panliang/owl-admin-starter
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Admin\Services\PartyUserService;
|
|
|
|
class AccountController extends Controller
|
|
{
|
|
public function profile()
|
|
{
|
|
$user = auth('api')->user();
|
|
|
|
return $this->response()->success([
|
|
'id' => $user->id,
|
|
'name' => $user->name,
|
|
'avatar' => $user->avatar,
|
|
'cate_id' => $user->cate_id,
|
|
'cate_name' => $user->cate?->name,
|
|
'current_score' => $user->current_score,
|
|
'score' => $user->score,
|
|
'scores' => $user->scores,
|
|
]);
|
|
}
|
|
|
|
public function chartOption()
|
|
{
|
|
$user = auth('api')->user();
|
|
$option = PartyUserService::make()->getChartOption($user);
|
|
|
|
return $this->response()->success($option);
|
|
}
|
|
|
|
public function update(Request $request)
|
|
{
|
|
$user = auth('api')->user();
|
|
$service = PartyUserService::make();
|
|
if ($service->update($user->id, $request->only(['name', 'avatar']))) {
|
|
return $this->response()->success('保存成功');
|
|
}
|
|
return $this->response()->fail($service->getError());
|
|
}
|
|
|
|
public function logout()
|
|
{
|
|
$user = auth('api')->user();
|
|
|
|
$user->currentAccessToken()->delete();
|
|
|
|
return $this->response()->success();
|
|
}
|
|
}
|