2019-12-10 21:25:54 +01:00
|
|
|
<?php
|
2020-09-07 12:18:56 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-09-07 12:18:56 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-09-07 12:18:56 +02:00
|
|
|
*/
|
2019-12-10 21:25:54 +01:00
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2020-03-09 10:38:15 +01:00
|
|
|
use App\DataMapper\CompanySettings;
|
2020-02-17 10:37:44 +01:00
|
|
|
use App\DataMapper\DefaultSettings;
|
2019-12-22 11:28:41 +01:00
|
|
|
use App\Factory\ClientFactory;
|
2020-02-15 12:49:31 +01:00
|
|
|
use App\Factory\InvoiceFactory;
|
|
|
|
use App\Factory\InvoiceInvitationFactory;
|
2020-10-26 20:10:04 +01:00
|
|
|
use App\Jobs\Invoice\CreateEntityPdf;
|
2021-06-08 12:39:07 +02:00
|
|
|
use App\Jobs\Mail\NinjaMailerJob;
|
|
|
|
use App\Jobs\Mail\NinjaMailerObject;
|
|
|
|
use App\Mail\Migration\MaxCompanies;
|
2019-12-10 21:25:54 +01:00
|
|
|
use App\Mail\TemplateEmail;
|
2020-10-01 12:49:47 +02:00
|
|
|
use App\Models\Account;
|
2019-12-22 11:28:41 +01:00
|
|
|
use App\Models\Client;
|
|
|
|
use App\Models\ClientContact;
|
2020-10-01 12:49:47 +02:00
|
|
|
use App\Models\Company;
|
2019-12-10 21:25:54 +01:00
|
|
|
use App\Models\User;
|
2020-10-28 11:10:49 +01:00
|
|
|
use Faker\Factory;
|
2019-12-10 21:25:54 +01:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
|
|
|
|
class SendTestEmails extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'ninja:send-test-emails';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Sends Test Emails to check templates';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2020-10-28 11:10:49 +01:00
|
|
|
$faker = Factory::create();
|
2020-02-15 12:49:31 +01:00
|
|
|
|
2021-06-08 12:39:07 +02:00
|
|
|
$account = Account::factory()->create();
|
|
|
|
|
|
|
|
$user = User::factory()->create([
|
|
|
|
'account_id' => $account->id,
|
|
|
|
'confirmation_code' => '123',
|
|
|
|
'email' => $faker->safeEmail,
|
|
|
|
'first_name' => 'John',
|
|
|
|
'last_name' => 'Doe',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$company = Company::factory()->create([
|
|
|
|
'account_id' => $account->id,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$user->companies()->attach($company->id, [
|
|
|
|
'account_id' => $account->id,
|
|
|
|
'is_owner' => 1,
|
|
|
|
'is_admin' => 1,
|
|
|
|
'is_locked' => 0,
|
|
|
|
'permissions' => '',
|
|
|
|
'notifications' => CompanySettings::notificationDefaults(),
|
|
|
|
//'settings' => DefaultSettings::userSettings(),
|
|
|
|
'settings' => null,
|
|
|
|
]);
|
|
|
|
|
|
|
|
$nmo = new NinjaMailerObject;
|
|
|
|
$nmo->mailable = new MaxCompanies($user->account->companies()->first());
|
|
|
|
$nmo->company = $user->account->companies()->first();
|
|
|
|
$nmo->settings = $user->account->companies()->first()->settings;
|
|
|
|
$nmo->to_user = $user;
|
|
|
|
|
|
|
|
NinjaMailerJob::dispatchNow($nmo);
|
2019-12-10 21:25:54 +01:00
|
|
|
}
|
|
|
|
}
|