-
app/Livewire/Modals/Users/AddUserModal.php
Open in GitHubuse App\Models\User; use Carbon\Carbon; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Password; use Illuminate\Support\Str; use LivewireUI\Modal\ModalComponent; class AddUserModal extends ModalComponent { // ... public function addUser() { $this->validate(); $user = new User([ 'name' => $this->name, 'contact_name' => $this->name, 'email' => $this->email, 'email_verified_at' => Carbon::now()->format('Y-m-d H:i:s'), 'is_admin' => $this->is_admin, 'password' => Hash::make(Str::random(8)), // temporary password ]); $user->save(); $this->dispatch('refreshUsersList'); $this->closeModal(); $status = Password::sendResetLink(['email' => $this->email]); if ($status === Password::RESET_LINK_SENT) { $this->dispatch('notify', ['type' => 'success', 'message' => __('notifications.user_add_success')]); } else { $this->dispatch('notify', ['type' => 'error', 'message' => __('notifications.user_add_error')]); } } // ... }
-
app/Livewire/Users/UsersIndex.php
Open in GitHubclass UsersIndex extends Component { // ... protected $listeners = [ 'refreshUsersList' => '$refresh', ]; // ... }
-
composer.json
Open in GitHub{ // ... "require": { "// ... "filament/notifications": "^3.2", "livewire/livewire": "^3.3", "wire-elements/modal": "^2.0" }, // ... }