Closed fbunadi closed 2 months ago
Which method do you want to trigger?
The token should be in the $oathUser
.
Hi Bram,
I created a job which need to be executed when there is a new user is created.
Here's my UserObserver.php
namespace App\Observers;
use App\Models\User;
use Illuminate\Support\Facades\Log;
use App\Jobs\StoreUserEnrolledCourses;
class UserObserver
{
/**
* Handle the User "created" event.
*/
public function created(User $user): void
{
Log::debug('HELLO THERE');
StoreUserEnrolledCourses::dispatch($user);
}
/**
* Handle the User "updated" event.
*/
public function updated(User $user): void
{
//
}
/**
* Handle the User "deleted" event.
*/
public function deleted(User $user): void
{
//
}
/**
* Handle the User "restored" event.
*/
public function restored(User $user): void
{
//
}
/**
* Handle the User "force deleted" event.
*/
public function forceDeleted(User $user): void
{
//
}
}
Hi Bram,
Nevermind, it works now. The UserObserver gets executed after a user is created. Thank you so much for your help.
If you want it to execute just before creation, you can use the creating
function on the observer instead of created
Hi, please bear with me. I'm still new to Laravel and Filament. I have a few questions regarding this plugin.
UserObserver didn't get triggered when a new user is created
If I removed the below code from AppServiceProvider, User::observe(UserObserver::class) gets called when a new user is created in the user table. However it didn't get triggered when I have the below code.
Here's my AppServiceProvider.php