|
- <?php
-
- namespace App\Http\Controllers\Web\Auth;
-
- use App\Models\User;
- use App\Codes\UserRole;
- use App\Features\LoginUser;
- use Illuminate\Support\Arr;
- use Illuminate\Support\Facades\Auth;
-
- trait Me
- {
-
- use LoginUser;
-
- protected function me()
- {
- if (Auth::check()) {
- $user = Auth::user();
-
- $filteredUser = Arr::only($user->toArray(), [
- User::COL_NAME_ID,
- User::COL_NAME_CONTRACT_ID,
- User::COL_NAME_ROLE,
- User::COL_NAME_NAME,
- ]);
-
- $contract = $this->loginUser()->getCurrentContract();
- if ($contract) {
- $filteredUser[User::COL_NAME_CONTRACT_ID] = $contract->id;
- $filteredUser['contract_name'] = $contract->name;
- $filteredUser['custom'] = $contract->custom();
- };
- return $filteredUser;
- }
- return null;
- }
- }
|