FleetCart/Modules/User/Services/CustomerService.php
2023-06-11 13:14:03 +01:00

35 lines
828 B
PHP

<?php
namespace Modules\User\Services;
use Modules\User\Entities\Role;
use Modules\User\Contracts\Authentication;
class CustomerService
{
private $auth;
public function __construct(Authentication $auth)
{
$this->auth = $auth;
}
public function register($request)
{
return tap($this->auth->registerAndActivate($this->getCustomerData($request)), function ($user) {
$role = Role::find(setting('customer_role'));
$user->roles()->attach($role);
});
}
private function getCustomerData($request)
{
return array_merge($request->billing, [
'email' => $request->customer_email,
'phone' => $request->customer_phone,
'password' => $request->password,
]);
}
}