AuthController.php
1.14 KB
<?php
namespace App\Http\Container\ManageSection\Controllers;
use App\Http\Request\UserChangePwdRequest;
use App\Models\SystemPermission;
use App\Support\Controller;
use Hikoon\LaravelApi\Facades\Response;
use Hikoon\LaravelApi\Support\ApiCode;
use Illuminate\Http\Request;
class AuthController extends Controller
{
/**
* @param \Illuminate\Http\Request $request
* @return \Hikoon\LaravelApi\Facades\Response
*/
public function show(Request $request): Response
{
return $this->successWithData([
'user' => $request->user()->only(['id', 'nick_name', 'avatar']),
'permissions' => SystemPermission::filter(['guard' => 'Manage'])->pluck('name'),
'menus' => SystemPermission::filter(['guard' => 'Manage'])->latest('weight')->get(),
]);
}
/**
* @param \App\Http\Request\UserChangePwdRequest $request
* @return \Hikoon\LaravelApi\Facades\Response
*/
public function changePwd(UserChangePwdRequest $request): Response
{
$request->user()->update($request->safe()->toArray());
return $this->success(ApiCode::UPDATE_SUCCESS);
}
}