2018-06-25 09:01:45 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* ReportNewJournalsMail.php
|
2020-02-07 04:16:38 -06:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2018-06-25 09:01:45 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2018-06-25 09:01:45 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2018-06-25 09:01:45 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2018-06-25 09:01:45 -05:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-01 23:37:26 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
2018-06-25 09:01:45 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-06-25 09:01:45 -05:00
|
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace FireflyIII\Mail;
|
|
|
|
|
2019-08-18 04:16:33 -05:00
|
|
|
use FireflyIII\Models\TransactionGroup;
|
|
|
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
2018-06-25 09:01:45 -05:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ReportNewJournalsMail.
|
|
|
|
*
|
|
|
|
* Sends a list of newly created journals to the user.
|
2019-08-17 03:47:29 -05:00
|
|
|
*
|
2019-07-31 09:53:09 -05:00
|
|
|
* @codeCoverageIgnore
|
2018-06-25 09:01:45 -05:00
|
|
|
*/
|
|
|
|
class ReportNewJournalsMail extends Mailable
|
|
|
|
{
|
|
|
|
use Queueable, SerializesModels;
|
|
|
|
|
|
|
|
/** @var string Email address of the user */
|
|
|
|
public $email;
|
2019-08-18 04:16:33 -05:00
|
|
|
/** @var Collection A collection of groups */
|
|
|
|
public $groups;
|
2020-03-17 10:46:00 -05:00
|
|
|
/** @var string IP address of user (if known) */
|
|
|
|
public $ipAddress;
|
2019-08-18 04:16:33 -05:00
|
|
|
/** @var array All groups, transformed to array. */
|
|
|
|
public $transformed;
|
2018-06-25 09:01:45 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ConfirmEmailChangeMail constructor.
|
|
|
|
*
|
|
|
|
* @param string $email
|
|
|
|
* @param string $ipAddress
|
2019-08-18 04:16:33 -05:00
|
|
|
* @param Collection $groups
|
2018-06-25 09:01:45 -05:00
|
|
|
*/
|
2019-08-18 04:16:33 -05:00
|
|
|
public function __construct(string $email, string $ipAddress, Collection $groups)
|
2018-06-25 09:01:45 -05:00
|
|
|
{
|
|
|
|
$this->email = $email;
|
|
|
|
$this->ipAddress = $ipAddress;
|
2019-08-18 04:16:33 -05:00
|
|
|
$this->groups = $groups;
|
2018-06-25 09:01:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build the message.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function build(): self
|
|
|
|
{
|
2019-08-18 04:16:33 -05:00
|
|
|
$this->transform();
|
2018-06-27 23:31:31 -05:00
|
|
|
|
2018-06-25 09:01:45 -05:00
|
|
|
return $this->view('emails.report-new-journals-html')->text('emails.report-new-journals-text')
|
2020-05-28 23:12:24 -05:00
|
|
|
->subject((string) trans_choice('email.new_journals_subject', $this->groups->count()));
|
2018-06-25 09:01:45 -05:00
|
|
|
}
|
2019-08-18 04:16:33 -05:00
|
|
|
|
|
|
|
private function transform(): void
|
|
|
|
{
|
|
|
|
/** @var TransactionGroupTransformer $transformer */
|
|
|
|
$transformer = app(TransactionGroupTransformer::class);
|
|
|
|
|
|
|
|
/** @var TransactionGroup $group */
|
|
|
|
foreach ($this->groups as $group) {
|
|
|
|
$this->transformed[] = $transformer->transformObject($group);
|
|
|
|
}
|
|
|
|
}
|
2018-06-25 09:01:45 -05:00
|
|
|
}
|