領収証発行サービス
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.

39 lines
934B

  1. <?php
  2. namespace App\Http\Controllers\Web\Auth;
  3. use App\Models\User;
  4. use App\Codes\UserRole;
  5. use App\Features\LoginUser;
  6. use Illuminate\Support\Arr;
  7. use Illuminate\Support\Facades\Auth;
  8. trait Me
  9. {
  10. use LoginUser;
  11. protected function me()
  12. {
  13. if (Auth::check()) {
  14. $user = Auth::user();
  15. $filteredUser = Arr::only($user->toArray(), [
  16. User::COL_NAME_ID,
  17. User::COL_NAME_CONTRACT_ID,
  18. User::COL_NAME_ROLE,
  19. User::COL_NAME_NAME,
  20. ]);
  21. $contract = $this->loginUser()->getCurrentContract();
  22. if ($contract) {
  23. $filteredUser[User::COL_NAME_CONTRACT_ID] = $contract->id;
  24. $filteredUser['contract_name'] = $contract->name;
  25. $filteredUser['custom'] = $contract->custom();
  26. };
  27. return $filteredUser;
  28. }
  29. return null;
  30. }
  31. }