You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?php
-
- namespace App\Http\Controllers\Web\Auth;
-
- use App\Exceptions\AppCommonException;
- use App\Sessions\SessionUser;
- use Illuminate\Support\Facades\Auth;
-
- trait Me
- {
- public function me(): array
- {
- if (!Auth::check()) {
- throw new AppCommonException("Me失敗");
- }
-
- $sessionUser = SessionUser::instance();
-
-
- $ret = Auth::user()->toArray();
-
- if ($sessionUser->isSwtiched()) {
- $ret['switched_user_id'] = $sessionUser->user()->id;
- $ret['switched_role'] = $sessionUser->user()->role;
- $ret['switched_name'] = $sessionUser->user()->name;
- } else {
- $ret['switched_user_id'] = null;
- $ret['switched_role'] = null;
- $ret['switched_name'] = null;
- }
-
- return $ret;
- }
- }
|