1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Services/User/UserService.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2021-03-03 23:39:24 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2023-01-28 23:21:40 +01:00
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
2021-03-03 23:39:24 +01:00
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-03-03 23:39:24 +01:00
*/
namespace App\Services\User;
use App\Jobs\Mail\NinjaMailer;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Mail\Admin\VerifyUserObject;
2023-10-02 08:20:26 +02:00
use App\Models\Company;
2021-03-03 23:39:24 +01:00
use App\Models\User;
use App\Utils\Ninja;
class UserService
{
2023-10-02 07:31:14 +02:00
public function __construct(public User $user)
2021-03-03 23:39:24 +01:00
{
}
2024-01-14 05:05:00 +01:00
public function invite(Company $company, bool $is_react = true)
2021-03-03 23:39:24 +01:00
{
2023-10-02 07:31:14 +02:00
2021-03-03 23:39:24 +01:00
try {
2024-01-14 05:05:00 +01:00
$nmo = new NinjaMailerObject();
2023-10-02 07:31:14 +02:00
$nmo->mailable = new NinjaMailer((new VerifyUserObject($this->user, $company, $is_react))->build());
2021-03-03 23:39:24 +01:00
$nmo->company = $company;
$nmo->to_user = $this->user;
$nmo->settings = $company->settings;
NinjaMailerJob::dispatch($nmo, true);
2021-03-03 23:39:24 +01:00
Ninja::registerNinjaUser($this->user);
} catch (\Exception $e) {
nlog("I couldn't send the verification email ".$e->getMessage());
2021-03-03 23:39:24 +01:00
}
return $this->user;
}
}