show user first impl.
This commit is contained in:
@@ -24,7 +24,15 @@ export default class UsersController {
|
|||||||
|
|
||||||
public async store({}: HttpContextContract) {}
|
public async store({}: HttpContextContract) {}
|
||||||
|
|
||||||
public async show({}: HttpContextContract) {}
|
public async show({ bouncer, params, inertia }: HttpContextContract) {
|
||||||
|
const queriedUser: User = await User.findByOrFail('id', params.id)
|
||||||
|
|
||||||
|
await bouncer
|
||||||
|
.with('UserPolicy')
|
||||||
|
.authorize('show', queriedUser)
|
||||||
|
|
||||||
|
return inertia.render('Users/Show', { queriedUser })
|
||||||
|
}
|
||||||
|
|
||||||
public async edit({}: HttpContextContract) {}
|
public async edit({}: HttpContextContract) {}
|
||||||
|
|
||||||
|
|||||||
1
components.d.ts
vendored
1
components.d.ts
vendored
@@ -10,6 +10,7 @@ declare module 'vue' {
|
|||||||
NButton: typeof import('naive-ui')['NButton']
|
NButton: typeof import('naive-ui')['NButton']
|
||||||
NForm: typeof import('naive-ui')['NForm']
|
NForm: typeof import('naive-ui')['NForm']
|
||||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||||
|
NIcon: typeof import('naive-ui')['NIcon']
|
||||||
NInput: typeof import('naive-ui')['NInput']
|
NInput: typeof import('naive-ui')['NInput']
|
||||||
NMenu: typeof import('naive-ui')['NMenu']
|
NMenu: typeof import('naive-ui')['NMenu']
|
||||||
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
|
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
|
||||||
|
|||||||
@@ -7,26 +7,34 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script lang="ts" setup>
|
||||||
import { Link, usePage } from '@inertiajs/vue3'
|
import { Link, usePage } from '@inertiajs/vue3'
|
||||||
import { h, ref, watch } from 'vue';
|
import { h, ref } from 'vue';
|
||||||
import { NIcon, NButton } from 'naive-ui'
|
import type { Ref, Component } from 'vue'
|
||||||
|
import type { MenuOption } from 'naive-ui'
|
||||||
|
import type { User } from '../types/User'
|
||||||
|
import { NIcon } from 'naive-ui'
|
||||||
import {
|
import {
|
||||||
GroupsFilled as Users,
|
GroupsFilled as Users,
|
||||||
EventNoteFilled as Events,
|
EventNoteFilled as Events,
|
||||||
LogOutFilled as Logout
|
LogOutFilled as Logout,
|
||||||
|
SettingsRound as Settings,
|
||||||
|
PersonRound as Profile,
|
||||||
} from '@vicons/material'
|
} from '@vicons/material'
|
||||||
|
|
||||||
const { request, isAdmin } = usePage().props
|
const activeKey: Ref<string> = ref((usePage().props.request as any)?.url)
|
||||||
const activeKey = ref(request.url)
|
const user: User = usePage().props.user as User
|
||||||
|
|
||||||
|
console.log(usePage().props.request)
|
||||||
|
|
||||||
const menuOptions = ref([])
|
const menuOptions: MenuOption[] = []
|
||||||
menuOptions.value.push({
|
|
||||||
|
menuOptions.push({
|
||||||
label: () =>
|
label: () =>
|
||||||
h(
|
h(
|
||||||
Link, {
|
Link, {
|
||||||
href: "/events",
|
href: "/events",
|
||||||
methode: "get"
|
method: "get"
|
||||||
},
|
},
|
||||||
() => "Veranstaltungen"
|
() => "Veranstaltungen"
|
||||||
),
|
),
|
||||||
@@ -34,7 +42,7 @@
|
|||||||
icon: renderIcon(Events)
|
icon: renderIcon(Events)
|
||||||
})
|
})
|
||||||
|
|
||||||
if(isAdmin) menuOptions.value.push({
|
if(user.is_admin) menuOptions.push({
|
||||||
label: () =>
|
label: () =>
|
||||||
h(
|
h(
|
||||||
Link, {
|
Link, {
|
||||||
@@ -47,9 +55,25 @@
|
|||||||
icon: renderIcon(Users)
|
icon: renderIcon(Users)
|
||||||
})
|
})
|
||||||
|
|
||||||
menuOptions.value.push({
|
menuOptions.push({
|
||||||
label: () =>
|
label: "Einstellungen",
|
||||||
h(
|
key: "einstellungen",
|
||||||
|
icon: renderIcon(Settings),
|
||||||
|
children: [{
|
||||||
|
label: () => h(
|
||||||
|
Link, {
|
||||||
|
href: "/users/"+user.id,
|
||||||
|
method: "get",
|
||||||
|
as: "button"
|
||||||
|
},
|
||||||
|
() => "Mein Profil"
|
||||||
|
),
|
||||||
|
key: 'profile',
|
||||||
|
icon: renderIcon(Profile)
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: () => h(
|
||||||
Link, {
|
Link, {
|
||||||
href: "/logout",
|
href: "/logout",
|
||||||
method: "post",
|
method: "post",
|
||||||
@@ -59,11 +83,15 @@
|
|||||||
),
|
),
|
||||||
key: '/logout',
|
key: '/logout',
|
||||||
icon: renderIcon(Logout)
|
icon: renderIcon(Logout)
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
menuOptions.push({
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function renderIcon(icon) {
|
function renderIcon(icon: Component) {
|
||||||
return () => h(NIcon, null, { default: () => h(icon) })
|
return () => h(NIcon, null, { default: () => h(icon) })
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
12
resources/js/pages/Users/Show.vue
Normal file
12
resources/js/pages/Users/Show.vue
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import BELayout from '@/layouts/BELayout.vue'
|
||||||
|
//import FlashMessages from '@/components/FlashMessages.vue'
|
||||||
|
|
||||||
|
defineOptions({ layout: BELayout })
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
10
resources/js/types/User.ts
Normal file
10
resources/js/types/User.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { DateTime } from 'luxon'
|
||||||
|
|
||||||
|
export type User = {
|
||||||
|
id: Number,
|
||||||
|
username: String,
|
||||||
|
is_admin: Boolean,
|
||||||
|
updated_at: DateTime,
|
||||||
|
created_at: DateTime,
|
||||||
|
remember_me_token: String | null,
|
||||||
|
}
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
import Inertia from '@ioc:EidelLev/Inertia'
|
import Inertia from '@ioc:EidelLev/Inertia'
|
||||||
|
|
||||||
Inertia.share({
|
Inertia.share({
|
||||||
//errors: ({session}) => session.flashMessages.get('errors'),
|
errors: ({ session }) => session.flashMessages.get('errors'),
|
||||||
request: ({ request }) => request,
|
request: ({ request }) => request,
|
||||||
isAdmin: ({ auth }) => auth.user?.isAdmin,
|
user: ({ auth }) => auth.user,
|
||||||
flashMessages: ({ session }) => session.flashMessages.all(),
|
flashMessages: ({ session }) => session.flashMessages.all(),
|
||||||
}).version(() => Inertia.manifestFile('public/assets/manifest.json'))
|
}).version(() => Inertia.manifestFile('public/assets/manifest.json'))
|
||||||
|
|||||||
Reference in New Issue
Block a user