client = $client; $this->full_name = $client->full_name; $this->national_id = $client->national_id ?? ''; $this->email = $client->email; $this->phone = $client->phone ?? ''; $this->preferred_language = $client->preferred_language ?? 'ar'; $this->status = $client->status->value; } public function rules(): array { return [ 'full_name' => ['required', 'string', 'max:255'], 'national_id' => ['required', 'string', 'max:50', Rule::unique('users', 'national_id')->ignore($this->client->id)], 'email' => ['required', 'email', 'max:255', Rule::unique('users', 'email')->ignore($this->client->id)], 'phone' => ['required', 'string', 'max:20'], 'password' => ['nullable', 'string', 'min:8'], 'preferred_language' => ['required', 'in:ar,en'], 'status' => ['required', 'in:active,deactivated'], ]; } public function messages(): array { return [ 'national_id.unique' => __('clients.national_id_exists'), 'email.unique' => __('clients.email_exists'), ]; } public function update(): void { $validated = $this->validate(); $oldValues = $this->client->only(['full_name', 'email', 'national_id', 'phone', 'preferred_language', 'status']); $this->client->full_name = $validated['full_name']; $this->client->national_id = $validated['national_id']; $this->client->email = $validated['email']; $this->client->phone = $validated['phone']; $this->client->preferred_language = $validated['preferred_language']; $this->client->status = $validated['status']; if (! empty($validated['password'])) { $this->client->password = Hash::make($validated['password']); } $this->client->save(); AdminLog::create([ 'admin_id' => auth()->id(), 'action' => 'update', 'target_type' => 'user', 'target_id' => $this->client->id, 'old_values' => $oldValues, 'new_values' => $this->client->only(['full_name', 'email', 'national_id', 'phone', 'preferred_language', 'status']), 'ip_address' => request()->ip(), 'created_at' => now(), ]); session()->flash('success', __('clients.client_updated')); $this->redirect(route('admin.clients.individual.index'), navigate: true); } public function with(): array { return [ 'statuses' => UserStatus::cases(), ]; } }; ?>
{{ __('clients.back_to_clients') }}
{{ __('clients.edit_client') }} {{ $client->full_name }}
{{ __('clients.full_name') }} * {{ __('clients.national_id') }} * {{ __('clients.email') }} * {{ __('clients.phone') }} * {{ __('clients.password') }} {{ __('clients.preferred_language') }} * {{ __('clients.arabic') }} {{ __('clients.english') }} {{ __('clients.status') }} * @foreach ($statuses as $statusOption) {{ __('clients.' . $statusOption->value) }} @endforeach
{{ __('clients.cancel') }} {{ __('clients.update') }}