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

41 lines
997B

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