2020-01-27 21:56:48 +01:00
|
|
|
<?php
|
2023-02-09 04:06:41 +01:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2023-02-09 04:06:41 +01:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
2020-01-27 21:56:48 +01:00
|
|
|
namespace App\Mail;
|
|
|
|
|
2023-02-09 04:06:41 +01:00
|
|
|
use App\Exceptions\ClientHostedMigrationException;
|
2021-06-09 17:25:59 +02:00
|
|
|
use App\Models\Company;
|
2020-01-27 21:56:48 +01:00
|
|
|
use Illuminate\Mail\Mailable;
|
2021-12-18 22:43:25 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2020-01-27 21:56:48 +01:00
|
|
|
|
|
|
|
class MigrationFailed extends Mailable
|
|
|
|
{
|
|
|
|
public $exception;
|
2021-06-09 17:25:59 +02:00
|
|
|
|
2020-03-05 21:30:32 +01:00
|
|
|
public $content;
|
2021-06-09 17:25:59 +02:00
|
|
|
|
2021-05-26 05:17:22 +02:00
|
|
|
public $company;
|
2021-06-09 17:25:59 +02:00
|
|
|
|
2021-08-10 03:40:58 +02:00
|
|
|
public $is_system = false;
|
|
|
|
|
2020-01-27 21:56:48 +01:00
|
|
|
/**
|
|
|
|
* Create a new message instance.
|
|
|
|
*
|
2020-03-05 21:30:32 +01:00
|
|
|
* @param $content
|
2020-01-27 21:56:48 +01:00
|
|
|
* @param $exception
|
|
|
|
*/
|
2021-06-09 17:25:59 +02:00
|
|
|
public function __construct($exception, Company $company, $content = null)
|
2020-01-27 21:56:48 +01:00
|
|
|
{
|
|
|
|
$this->exception = $exception;
|
2021-02-10 02:59:30 +01:00
|
|
|
$this->content = $content;
|
2021-05-26 05:17:22 +02:00
|
|
|
$this->company = $company;
|
2020-01-27 21:56:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the message.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function build()
|
|
|
|
{
|
2021-12-18 22:43:25 +01:00
|
|
|
App::setLocale($this->company->getLocale());
|
2024-01-14 05:05:00 +01:00
|
|
|
|
2023-02-09 04:06:41 +01:00
|
|
|
$special_message = '';
|
|
|
|
|
2023-02-16 02:36:09 +01:00
|
|
|
if ($this->exception instanceof ClientHostedMigrationException) {
|
2023-02-09 04:06:41 +01:00
|
|
|
$special_message = $this->content;
|
2023-02-16 02:36:09 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
2021-06-09 17:25:59 +02:00
|
|
|
return $this
|
|
|
|
->from(config('mail.from.address'), config('mail.from.name'))
|
2022-03-04 01:45:19 +01:00
|
|
|
->text('email.migration.failed_text')
|
2021-06-09 17:25:59 +02:00
|
|
|
->view('email.migration.failed', [
|
2023-02-09 04:06:41 +01:00
|
|
|
'special_message' => $special_message,
|
2021-06-09 17:25:59 +02:00
|
|
|
'logo' => $this->company->present()->logo(),
|
|
|
|
'settings' => $this->company->settings,
|
2021-08-10 03:40:58 +02:00
|
|
|
'is_system' => $this->is_system,
|
2021-06-09 17:25:59 +02:00
|
|
|
]);
|
2020-01-27 21:56:48 +01:00
|
|
|
}
|
|
|
|
}
|