Fix email generation and sending via CLI

This commit is contained in:
Deon George
2022-08-25 11:08:10 +10:00
parent 8955df84cd
commit 39db6303c2
3 changed files with 9 additions and 8 deletions

View File

@@ -5,7 +5,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
use App\Models\{Account,Invoice};
use App\Models\{Account,Invoice,Site};
class InvoiceGenerate extends Command
{
@@ -14,7 +14,7 @@ class InvoiceGenerate extends Command
*
* @var string
*/
protected $signature = 'invoice:generate {account?} {--p|preview : Preview} {--l|list : List Items}';
protected $signature = 'invoice:generate {site} {account?} {--p|preview : Preview} {--l|list : List Items}';
/**
* The console command description.
@@ -30,14 +30,14 @@ class InvoiceGenerate extends Command
*/
public function handle()
{
Config::set('site',Site::findOrFail($this->argument('site')));
if ($this->argument('account'))
$accounts = collect()->push(Account::find($this->argument('account')));
else
$accounts = Account::active()->get();
foreach ($accounts as $o) {
Config::set('site',$o->site);
$io = new Invoice;
$io->account_id = $o->id;