guard()->user(); $admin = $user->adminUser; return [ 'id' => $user->id, 'name' => $user->name, 'phone' => $user->phone, 'avatar' => $user->avatar, 'jobs' => KeywordResource::collection($user->jobs), 'unread_notifications' => 0, // 身份: user-普通员工, store-店长, admin-管理员 'role' => $user->userRole(), ]; } // 修改账户信息 public function update(Request $request) { $user = $this->guard()->user(); try { DB::beginTransaction(); $service = EmployeeService::make(); $data = $request->only(['name', 'avatar', 'password', 'confirm_password', 'phone']); if (!$service->update($user->id, $data)) { throw new RuntimeException($service->getError()); } DB::commit(); } catch (\Exception $e) { DB::rollback(); throw new RuntimeException($e->getMessage()); } return response('', Response::HTTP_OK); } // 门店列表 public function storeList(Request $request) { $user = $this->guard()->user(); $role = $user->userRole(); $query = Store::filter($request->all()); if ($role == UserRole::User || $role == UserRole::Store) { $query->whereIn('id', [$user->store_id]); } return $query->get(); } }