1
0
Fork 0

Adding user handling pages for admins.

This commit is contained in:
Henrik Hautakoski 2021-07-15 15:38:58 +02:00
parent c53a4155f4
commit bd21a64191
9 changed files with 485 additions and 0 deletions

View file

@ -0,0 +1,11 @@
<x-layout name="app">
<x-slot name="title">{{ __('Admin') }} - {{ __('Users') }} - {{ __(isset($model) ? 'Edit' : 'New') }}</x-slot>
@if (isset($model))
<livewire:form.admin.user-form :user="$model" />
@else
<livewire:form.admin.user-form />
@endif
</x-layout>

View file

@ -0,0 +1,13 @@
<x-layout name="app">
<x-slot name="title">{{ __('Admin') }} - {{ __('Users') }}</x-slot>
<x-slot name="page_links">
<x-button element="a" class="flex items-center" href="{{ route('admin.users.create') }}">
{{ __('New') }}
</x-button>
</x-slot>
<livewire:admin-user-table />
</x-layout>

View file

@ -0,0 +1,42 @@
<div class="p-4">
<table class="w-full">
<tr>
<th><x-input wire:model="username" name="username" placeholder="Username" /></th>
<th><x-select wire:model="role" name="role" :options="['' => '-- Role --', 'user' => 'User', 'admin' => 'Admin']" /></th>
</tr>
<tr class="border-b-2">
<th class="py-2 text-left">Username</th>
<th class="py-2 w-24">Role</th>
<th class="py-2 w-44">Created</th>
<th class="py-2 w-44">Updated</th>
<th class="py-2 w-6">&nbsp;</th>
</tr>
@foreach($users as $user)
<tr class="border-b hover:bg-gray-100">
<td class="px-2 py-1">
<x-link href="{{ route('admin.users.edit', [ 'user' => $user ]) }}">
{{ $user->username }}
</x-link>
</td>
<td class="px-2 py-1 text-center">{{ $user->role }}</td>
<td class="px-2 py-1">{{ $user->created_at }}</td>
<td class="px-2 py-1">{{ $user->updated_at }}</td>
<td>
<x-form :action="route('admin.users.destroy', [ 'user' => $user ])" method="DELETE">
<a href="#" onclick="this.closest('form').submit();return false;">
<x-icon name="cross" class="h-6 h-6 text-danger-400 hover:text-danger-600" />
</a>
</x-form>
</td>
</tr>
@endforeach
</table>
<div class="mt-4">
{{ $users->links() }}
</div>
</div>

View file

@ -0,0 +1,27 @@
<x-form class="p-4" wire:submit.prevent="save">
<div>
<x-form.label for="username">{{ __('Username') }}</x-form.label>
<x-input wire:model="user.username" name="user.username" label="username" />
</div>
<div>
<x-form.label for="role">{{ __('Role') }}</x-form.label>
<x-select wire:model="user.role" name="role" :options="['user' => 'User', 'admin' => 'Admin']" />
</div>
<div class="mb-2">
<x-form.label for="password">{{ __('Password') }}</x-form.label>
<x-input-password wire:model="password" name="password" />
</div>
<div class="mb-2">
<x-form.label for="password_confirmation">{{ __('Confirm Password') }}</x-form.label>
<x-input-password wire:model="password_confirmation" name="password_confirmation" />
</div>
<div class="mt-2">
<x-button element="input" type="submit" value="{{ $user->id ? 'Save' : 'Create' }}" />
</div>
</x-form>