Display nicename in dashboard
This commit is contained in:
@@ -8,6 +8,8 @@ const props = defineProps({
|
||||
user: Object,
|
||||
currentPath: String,
|
||||
})
|
||||
|
||||
console.log(props.user.nicename)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Providers;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Resources\UserResource;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
@@ -23,7 +24,7 @@ final class InertiaProvider
|
||||
public function render() : Response {
|
||||
$this->props['navbar'] = $this->generateNavbar();
|
||||
$this->props['tenant'] = app('tenant');
|
||||
$this->props['user'] = $this->user;
|
||||
$this->props['user'] = new UserResource($this->user)->toArray(request());
|
||||
$this->props['currentPath'] = request()->path();
|
||||
$this->props['availableLocalGroups'] = Tenant::where(['is_active_local_group' => true])->get();
|
||||
|
||||
|
||||
34
app/Resources/UserResource.php
Normal file
34
app/Resources/UserResource.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Resources;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class UserResource extends JsonResource {
|
||||
private User $user;
|
||||
|
||||
public function __construct(User $user) {
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function toArray($request) {
|
||||
$data = array_merge(
|
||||
$this->user->toArray(),
|
||||
[
|
||||
'nicename' => $this->user->getNicename(),
|
||||
'fullname' => $this->user->getFullName()
|
||||
]);
|
||||
|
||||
unset($data['password']);
|
||||
unset($data['remember_token']);
|
||||
unset($data['email_verified_at']);
|
||||
unset($data['created_at']);
|
||||
unset($data['updated_at']);
|
||||
unset($data['activation_token']);
|
||||
unset($data['activation_token_expires_at']);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
appName: String,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main style="padding: 2rem">
|
||||
<h1>{{ appName }}</h1>
|
||||
<p>Laravel + Inertia + Vue läuft 🚀</p>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -124,3 +124,12 @@ th {
|
||||
th:after {
|
||||
content: ":";
|
||||
}
|
||||
|
||||
#show_username {
|
||||
position: relative;
|
||||
top: -30px;
|
||||
width: calc(100% - 20px);
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@ const props = defineProps({
|
||||
tenant: String,
|
||||
currentPath: String,
|
||||
})
|
||||
|
||||
console.log(props.currentPath)
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -68,7 +65,11 @@ console.log(props.currentPath)
|
||||
|
||||
<div class="main">
|
||||
<div class="header">
|
||||
<div class="left-side"><h1>{{ props.title }}</h1></div>
|
||||
<div class="left-side">
|
||||
<h1>{{ props.title }}</h1>
|
||||
<label id="show_username" v-if="props.user !== null">Willkommen, {{ props.user.nicename }}</label>
|
||||
Test
|
||||
</div>
|
||||
<div class="user-info" v-if="props.user !== null">
|
||||
<a href="/messages" class="header-link-anonymous" title="Meine Nachrichten">
|
||||
<Icon name="envelope" />
|
||||
|
||||
Reference in New Issue
Block a user