osb/app/Console/Commands/InvoiceEmail.php

54 lines
879 B
PHP
Raw Permalink 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\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'
.' {--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()
{
Config::set(
'site',
$this->option('site')
? Site::findOrFail($this->option('site'))
: Site::where('url',config('app.url'))->sole()
);
2020-05-25 07:45:17 +00:00
$o = Invoice::findOrFail($this->argument('id'));
try {
$o->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
return self::SUCCESS;
2020-05-25 07:45:17 +00:00
}
}