I have created an observer called OfficeUserObserver and it's registered in my provider as well. I want a situation whereby when a user is attached to an office. A mail is automatically sent. So my observer looks thus:
class OfficeUserObserver
{
public function __construct()
{
dd('hi');
}
public function created(OfficeUser $officeUser)
{
dd('hi');
}
public function saving(OfficeUser $officeUser)
{
dd('hi');
}
}
My Controller looks thus:
public function assignUsers(MyRequest $request, Office $office)
{
...
$office->users()->syncWithoutDetaching($users);
}
When I however try to attach a user to an office. The process is successful but nothing ever gets dumped(dd()) on my view despite using dd() in my construct. What am I doing wrong please?
Here is the code in my AppServiceProvider
public function boot()
{
OfficeUser::observe(OfficeUserObserver::class);
}