add new role functionality

This commit is contained in:
Saufi
2026-05-11 12:29:11 +08:00
parent a300eced76
commit eaf0ba7a4d
7 changed files with 176 additions and 4 deletions

View File

@@ -0,0 +1,56 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('New Role') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="p-4 sm:p-8 bg-white dark:bg-gray-800 shadow sm:rounded-lg">
<div class="max-w-xl">
<section>
<header>
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('Role Details') }}
</h2>
<p class="mt-1 text-sm text-gray-600 dark:text-gray-400">
{{ __('Create a new role to assign to users in the system.') }}
</p>
</header>
<form method="post" action="{{ route('roles.store') }}" class="mt-6 space-y-6">
@csrf
<div>
<x-input-label for="name" :value="__('Name')" />
<x-text-input id="name" name="name" type="text" class="mt-1 block w-full" :value="old('name')" required autofocus autocomplete="off" />
<x-input-error class="mt-2" :messages="$errors->get('name')" />
</div>
<div>
<x-input-label for="description" :value="__('Description')" />
<textarea
id="description"
name="description"
rows="3"
class="mt-1 block w-full border-gray-300 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300 focus:border-indigo-500 dark:focus:border-indigo-600 focus:ring-indigo-500 dark:focus:ring-indigo-600 rounded-md shadow-sm"
>{{ old('description') }}</textarea>
<x-input-error class="mt-2" :messages="$errors->get('description')" />
</div>
<div class="flex items-center gap-4">
<x-primary-button>{{ __('Create Role') }}</x-primary-button>
<a href="{{ route('roles.index') }}" class="text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 underline">
{{ __('Cancel') }}
</a>
</div>
</form>
</section>
</div>
</div>
</div>
</div>
</x-app-layout>

View File

@@ -1,12 +1,29 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('Roles') }}
</h2>
<div class="flex items-center justify-between">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __('Roles') }}
</h2>
<a href="{{ route('roles.create') }}">
<x-primary-button>{{ __('New Role') }}</x-primary-button>
</a>
</div>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
@if (session('status') === 'role-created')
<div
x-data="{ show: true }"
x-show="show"
x-transition
x-init="setTimeout(() => show = false, 3000)"
class="mb-4 p-4 bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200 text-sm rounded-lg"
>
{{ __('Role created successfully.') }}
</div>
@endif
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
<div
class="p-6"