Skip to content

Commit

Permalink
Merge pull request #268 from lee-to/fix-header-profile
Browse files Browse the repository at this point in the history
fix(auth): Custom fields
  • Loading branch information
lee-to authored May 17, 2023
2 parents a88e14e + 05670e4 commit 1ba5400
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions resources/views/layouts/shared/notifications.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if(config('moonshine.use_notifications', true) && auth(config('moonshine.auth.guard'))->user()?->unreadNotifications?->isNotEmpty())
@if(config('moonshine.use_notifications', true) && auth()->user()?->unreadNotifications?->isNotEmpty())
<!-- Notifications -->
<div class="notifications">
<x-moonshine::dropdown
Expand All @@ -15,7 +15,7 @@ class="w-[264px] xs:w-80"
/>
</x-slot:toggler>

@foreach(auth(config('moonshine.auth.guard'))->user()->unreadNotifications as $notification)
@foreach(auth()->user()->unreadNotifications as $notification)
<div class="notifications-item">
<a href="{{ route('moonshine.notifications.read', $notification) }}"
class="notifications-remove"
Expand Down
10 changes: 6 additions & 4 deletions resources/views/layouts/shared/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
<a href="{{ route('moonshine.custom_page', 'profile') }}" class="menu-profile-main">
<div class="menu-profile-photo">
<img class="h-full w-full object-cover"
src="{{ auth(config('moonshine.auth.guard'))->user()->avatar ? (Storage::url(auth(config('moonshine.auth.guard'))->user()->avatar)) : ("https://ui-avatars.com/api/?name=" . auth(config('moonshine.auth.guard'))->user()->name) }}"
alt="{{ auth(config('moonshine.auth.guard'))->user()->name }}"
src="{{ auth()->user()->{config('moonshine.auth.fields.avatar', 'avatar')}
? (Storage::url(auth()->user()->{config('moonshine.auth.fields.avatar', 'avatar')}))
: ("https://ui-avatars.com/api/?name=" . auth()->user()->{config('moonshine.auth.fields.name', 'name')}) }}"
alt="{{ auth()->user()->{config('moonshine.auth.fields.name', 'name')} }}"
/>
</div>
<div class="menu-profile-info">
<h5 class="name">{{ auth(config('moonshine.auth.guard'))->user()->name }}</h5>
<div class="email">{{ auth(config('moonshine.auth.guard'))->user()->email }}</div>
<h5 class="name">{{ auth()->user()->{config('moonshine.auth.fields.name', 'name')} }}</h5>
<div class="email">{{ auth()->user()->{config('moonshine.auth.fields.username', 'email')} }}</div>
</div>
</a>

Expand Down
6 changes: 3 additions & 3 deletions resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
name="name"
@class(['form-invalid' => $errors->has('name')])
placeholder="{{ trans('moonshine::ui.resource.name') }}"
value="{{ old('name', auth(config('moonshine.auth.guard'))->user()
value="{{ old('name', auth()->user()
->{config('moonshine.auth.fields.name', 'name')}) }}"
/>
</x-moonshine::form.input-wrapper>
Expand All @@ -33,7 +33,7 @@
placeholder="{{ trans('moonshine::ui.login.username') }}"
autocomplete="username"
required
value="{{ old('username', auth(config('moonshine.auth.guard'))->user()
value="{{ old('username', auth()->user()
->{config('moonshine.auth.fields.username', 'email')}) }}"
/>
</x-moonshine::form.input-wrapper>
Expand Down Expand Up @@ -75,7 +75,7 @@
id="avatar"
@class(['form-invalid' => $errors->has('avatar')])
placeholder="{{ trans('moonshine::ui.resource.avatar') }}"
:files="[auth(config('moonshine.auth.guard'))->user()
:files="[auth()->user()
->{config('moonshine.auth.fields.avatar', 'avatar')} ?? null]"
dir="moonshine_users"
:path="Storage::disk('public')->url('/')"
Expand Down
4 changes: 2 additions & 2 deletions resources/views/ui/social-auth.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</div>

@if($attached ?? false)
@if(auth(config('moonshine.auth.guard'))->user()?->moonshineSocialites?->isNotEmpty())
@if(auth()->user()?->moonshineSocialites?->isNotEmpty())
<div class="social">
<div class="social-divider">@lang('moonshine::ui.resource.linked_socialite')</div>
<div class="social-list">
@foreach(auth(config('moonshine.auth.guard'))->user()->moonshineSocialites as $socials)
@foreach(auth()->user()->moonshineSocialites as $socials)
{{ $socials->driver }} - {{ $socials->identity }}
@endforeach
</div>
Expand Down

0 comments on commit 1ba5400

Please sign in to comment.