@extends('layouts.app') @section('title', $user->exists ? 'Edit User: ' . $user->name : 'Add New User') @section('content')

{{ $user->exists ? 'Edit User' : 'Add New User' }}

{{ $user->exists ? $user->email : 'Create a new system user and assign a role' }}

@if ($user->exists && !empty($isLastAdmin) && $isLastAdmin)
Last Admin: This is the only active admin. The role cannot be changed and the account cannot be deactivated.
@endif
@csrf @if ($user->exists) @method('PUT') @endif
{{-- Name --}}
@error('name')
{{ $message }}
@enderror
{{-- Email --}}
@error('email')
{{ $message }}
@enderror
{{-- Phone --}}
@error('phone')
{{ $message }}
@enderror
{{-- Role --}}
{{-- Hidden field when disabled so value is still submitted --}} @if (!empty($isLastAdmin) && $isLastAdmin) @endif @error('role')
{{ $message }}
@enderror
admin — full access • manager — operations • accountant — finance • sales — sales • store — inventory only
{{-- Password --}}
exists ? 'required' : '' }}> @error('password')
{{ $message }}
@enderror
{{-- Confirm Password --}}

@if ($user->exists) Created {{ $user->created_at?->diffForHumans() }} • Status: {{ $user->is_active ? 'Active' : 'Inactive' }} @endif
Cancel
@endsection