File: D:/HostingSpaces/SBogers10/conmeq.komma.pro/app/Komma/Auth/AuthMailService.php
<?php
namespace App\Komma\Auth;
use App\Komma\Shop\Orders\Kms\OrderMailService;
use App\Komma\Users\Models\KmsUser;
use App\Komma\Users\Models\KmsUserRole;
use App\Komma\Users\Models\SiteUser;
use App\Notifications\CustomerRegistered;
use App\Notifications\UserSetPassword;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Support\Facades\Password;
/**
* Class AuthMailService
*
* A service responsible for sending mails about authorisation and authentication.
*
* @see OrderMailService
* @package App\Komma\Auth
*/
final class AuthMailService implements AuthMailServiceInterface
{
/**
* Notify admins that a new user has been created
*
* @param $customer
* @return null
*/
public function notifyAdminsForNewCustomer(SiteUser $customer)
{
KmsUser::where('role', '=', KmsUserRole::Admin)->get()->each(function(KmsUser $admin) use ($customer) {
$admin->notify(new CustomerRegistered($customer));
\Log::debug('Notified admin with id: '.$admin->id.' that user with id '.$customer->id.' registered');
});
return null;
}
/**
* Notify user that he needs to set a password to login
*
* @param Authenticatable $user
* @return null
*/
public function notifyUserToSetPassword(Authenticatable $user)
{
$token = Password::getRepository()->create($user);
$user->notify(new UserSetPassword($user, $token));
return null;
}
}