Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

clockobot/clockobot

46 stars
3 code files
View clockobot/clockobot on GitHub

app/Livewire/Modals/Users/AddUserModal.php

Open in GitHub
use 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 GitHub
class 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"
},
 
// ...
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.