osb/app/Console/Commands/InvoiceEmail.php

51 lines
950 B
PHP
Raw Normal View History

2020-05-25 07:45:17 +00:00
<?php
namespace App\Console\Commands;
use Illuminate\Support\Facades\Config;
2020-05-25 07:45:17 +00:00
use Illuminate\Support\Facades\Mail;
use Illuminate\Console\Command;
use App\Models\{Invoice,Site};
2020-05-25 07:45:17 +00:00
class InvoiceEmail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'invoice:email {site} {id}';
2020-05-25 07:45:17 +00:00
/**
* The console command description.
*
* @var string
*/
protected $description = 'Email Invoices to be client';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Config::set('site',Site::findOrFail($this->argument('site')));
2020-05-25 07:45:17 +00:00
$o = Invoice::findOrFail($this->argument('id'));
2024-07-06 00:28:45 +00:00
$result = Mail::to($o->account->user->email)->send(new \App\Mail\InvoiceEmail($o));
2020-05-25 07:45:17 +00:00
try {
2020-05-25 07:45:17 +00:00
$o->print_status = TRUE;
2024-07-06 00:28:45 +00:00
//$o->reminders = $o->reminders('send');
2020-05-25 07:45:17 +00:00
$o->save();
} catch (\Exception $e) {
dd($e);
2020-05-25 07:45:17 +00:00
}
2024-07-06 00:28:45 +00:00
dump($result->getDebug());
2020-05-25 07:45:17 +00:00
}
}