Skip to content

Commit 3f068fb

Browse files
Add default global user profile variable
1 parent 6d83950 commit 3f068fb

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

app/Http/Middleware/HandleInertiaRequests.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public function share(Request $request): array
4646
'counts' => [
4747
'userCount' => User::count(),
4848
'roleCount' => Role::count(),
49-
]
49+
],
50+
'avatar' => 'https://painrehabproducts.com/wp-content/uploads/2014/10/facebook-default-no-profile-pic.jpg'
5051
]);
5152
}
52-
}
53+
}

resources/js/Pages/Profile/Show.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import AppLayout from '@/Layouts/AppLayout.vue';
33
import DeleteUserForm from '@/Pages/Profile/Partials/DeleteUserForm.vue';
44
import LogoutOtherBrowserSessionsForm from '@/Pages/Profile/Partials/LogoutOtherBrowserSessionsForm.vue';
55
import SectionBorder from '@/Components/SectionBorder.vue';
6+
avatar: thhis.$page.props.avatar
67
import TwoFactorAuthenticationForm from '@/Pages/Profile/Partials/TwoFactorAuthenticationForm.vue';
78
import UpdatePasswordForm from '@/Pages/Profile/Partials/UpdatePasswordForm.vue';
89
import UpdateProfileInformationForm from '@/Pages/Profile/Partials/UpdateProfileInformationForm.vue';
@@ -16,13 +17,13 @@ defineProps({
1617
<template>
1718
<AppLayout title="Profile">
1819
<template #header>
19-
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
20+
<h2 class="text-xl font-semibold leading-tight text-gray-800">
2021
Profile
2122
</h2>
2223
</template>
2324

2425
<div>
25-
<div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
26+
<div class="py-10 mx-auto max-w-7xl sm:px-6 lg:px-8">
2627
<div v-if="$page.props.jetstream.canUpdateProfileInformation">
2728
<UpdateProfileInformationForm :user="$page.props.auth.user" />
2829

@@ -36,10 +37,8 @@ defineProps({
3637
</div>
3738

3839
<div v-if="$page.props.jetstream.canManageTwoFactorAuthentication">
39-
<TwoFactorAuthenticationForm
40-
:requires-confirmation="confirmsTwoFactorAuthentication"
41-
class="mt-10 sm:mt-0"
42-
/>
40+
<TwoFactorAuthenticationForm :requires-confirmation="confirmsTwoFactorAuthentication"
41+
class="mt-10 sm:mt-0" />
4342

4443
<SectionBorder />
4544
</div>

resources/js/Pages/Users/Index.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<div class="overflow-hidden bg-white shadow-xl sm:rounded-lg">
2121

2222
<a href="#" @click="deleteSelectedUsers"
23-
class="float-left px-4 mt-3 py-2 text-red-400 duration-100 rounded hover:text-red-600">
24-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="h-6 w-6">
23+
class="float-left px-4 py-2 mt-3 text-red-400 duration-100 rounded hover:text-red-600">
24+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="w-6 h-6">
2525
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="currentColor"
2626
fill="none"
2727
d="M3 6h18M6 6l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 4v-1a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1" />
@@ -58,6 +58,10 @@
5858
class="px-6 py-3 text-xs font-medium tracking-wider text-center text-gray-500 uppercase">
5959
ID
6060
</th>
61+
<th scope="col"
62+
class="px-6 py-3 text-xs font-medium tracking-wider text-center text-gray-500 uppercase">
63+
Avatar
64+
</th>
6165
<th scope="col"
6266
class="px-6 py-3 text-xs font-medium tracking-wider text-center text-gray-500 uppercase">
6367
Name
@@ -90,6 +94,11 @@
9094
{{ user.id }}
9195
</div>
9296
</td>
97+
<td>
98+
<img class="w-10 h-10 mx-auto rounded-full"
99+
:src="user.avatar != 'placeholder' ? user.avatar : $page.props.avatar"
100+
alt="User profile image">
101+
</td>
93102
<td class="px-6 py-4 whitespace-nowrap">
94103
<div class="flex items-center justify-center">
95104

@@ -196,6 +205,13 @@ export default {
196205
alert('An error occurred while deleting the selected users.');
197206
}
198207
},
208+
computed: {
209+
userAvatar(user) {
210+
return this.user.avatar !== 'placeholder'
211+
? this.user.avatar
212+
: 'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png';
213+
}
214+
},
199215
}
200216
}
201217
</script>

resources/js/Pages/Users/Show.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default {
3030
AppLayout
3131
},
3232
props: {
33-
getUser: Object
33+
getUser: Object,
34+
avatar: String
3435
},
3536
data() {
3637
return {
@@ -41,7 +42,7 @@ export default {
4142
userAvatar() {
4243
return this.getUser.avatar !== 'placeholder'
4344
? this.getUser.avatar
44-
: 'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png';
45+
: this.$page.props.avatar;
4546
}
4647
},
4748
mounted() {

0 commit comments

Comments
 (0)