2020-05-25 07:45:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2022-03-05 00:05:35 +00:00
|
|
|
use Illuminate\Support\Facades\Config;
|
2020-05-25 07:45:17 +00:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
2022-08-25 01:08:10 +00:00
|
|
|
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
|
|
|
|
*/
|
2024-08-03 00:06:25 +00:00
|
|
|
protected $signature = 'invoice:email'
|
|
|
|
.' {--s|site : Site ID}'
|
|
|
|
.' {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()
|
|
|
|
{
|
2024-08-03 00:06:25 +00:00
|
|
|
Config::set(
|
|
|
|
'site',
|
|
|
|
$this->option('site')
|
|
|
|
? Site::findOrFail($this->option('site'))
|
|
|
|
: Site::where('url',config('app.url'))->sole()
|
|
|
|
);
|
2022-08-25 01:08:10 +00:00
|
|
|
|
2020-05-25 07:45:17 +00:00
|
|
|
$o = Invoice::findOrFail($this->argument('id'));
|
|
|
|
|
2022-05-12 04:34:14 +00:00
|
|
|
try {
|
2024-08-03 00:06:25 +00:00
|
|
|
$o->send();
|
2020-05-25 07:45:17 +00:00
|
|
|
$o->save();
|
2022-05-12 04:34:14 +00:00
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
dd($e);
|
2020-05-25 07:45:17 +00:00
|
|
|
}
|
2024-07-06 00:28:45 +00:00
|
|
|
|
2024-08-03 00:06:25 +00:00
|
|
|
return self::SUCCESS;
|
2020-05-25 07:45:17 +00:00
|
|
|
}
|
|
|
|
}
|