Work on products, first completed broadband
This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
use App\Models\Service;
|
||||
use App\Models\{Service,Site};
|
||||
|
||||
class ServiceList extends Command
|
||||
{
|
||||
@@ -15,10 +14,10 @@ class ServiceList extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'service:list '.
|
||||
'{--a|active : Active Only}'.
|
||||
'{--category= : Category}'.
|
||||
'{--f|fix : Fix start_date}';
|
||||
protected $signature = 'service:list'.
|
||||
' {--i|inactive : Include Inactive}'.
|
||||
' {--t|type= : Type}'.
|
||||
' {--f|fix : Fix start_date}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@@ -27,16 +26,6 @@ class ServiceList extends Command
|
||||
*/
|
||||
protected $description = 'List all services';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
@@ -44,13 +33,11 @@ class ServiceList extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
DB::listen(function($query) {
|
||||
Log::debug('- SQL',['sql'=>$query->sql,'binding'=>$query->bindings]);
|
||||
});
|
||||
$header = '|%13s|%-10s|%-35s|%-40s|%8s|%10s|%15s|%10s|%10s|%12s|%14s|';
|
||||
|
||||
$this->warn(sprintf('|%10s|%-6s|%-20s|%-50s|%8s|%14s|%10s|%10s|%10s|%10s|%10s|',
|
||||
$this->warn(sprintf($header,
|
||||
'ID',
|
||||
'CAT',
|
||||
'Type',
|
||||
'Product',
|
||||
'Name',
|
||||
'active',
|
||||
@@ -60,13 +47,15 @@ class ServiceList extends Command
|
||||
'stop date',
|
||||
'connect date',
|
||||
'first invoice'
|
||||
));
|
||||
));
|
||||
|
||||
foreach (Service::all() as $o) {
|
||||
if ($this->option('active') AND ! $o->isActive())
|
||||
foreach (Service::withoutGlobalScope(\App\Models\Scopes\SiteScope::class)->with(['site'])->cursor() as $o) {
|
||||
if ((! $this->option('inactive')) AND ! $o->isActive())
|
||||
continue;
|
||||
|
||||
if ($this->option('category') AND $o->product->category !== $this->option('category'))
|
||||
Config::set('site',$o->site);
|
||||
|
||||
if ($this->option('type') AND ($o->product->getProductTypeAttribute() !== $this->option('type')))
|
||||
continue;
|
||||
|
||||
$c = $o->invoice_items->filter(function($item) {return $item->item_type === 0; })->sortby('date_start')->first();
|
||||
@@ -76,10 +65,10 @@ class ServiceList extends Command
|
||||
$o->save();
|
||||
}
|
||||
|
||||
$this->info(sprintf('|%10s|%-6s|%-20s|%-50s|%8s|%14s|%10s|%10s|%10s|%10s|%10s|',
|
||||
$this->info(sprintf($header,
|
||||
$o->sid,
|
||||
$o->product->category,
|
||||
$o->product_name,
|
||||
$o->product->getProductTypeAttribute(),
|
||||
$o->product->getNameAttribute(),
|
||||
$o->name_short,
|
||||
$o->active ? 'active' : 'inactive',
|
||||
$o->status,
|
||||
@@ -87,7 +76,7 @@ class ServiceList extends Command
|
||||
$o->date_start ? $o->date_start->format('Y-m-d') : NULL,
|
||||
$o->date_end ? $o->date_end->format('Y-m-d') : NULL,
|
||||
($o->type AND $o->type->service_connect_date) ? $o->type->service_connect_date->format('Y-m-d') : NULL,
|
||||
$c ? $c->date_start->format('Y-m-d') : NULL,
|
||||
($c && $c->date_start) ? $c->date_start->format('Y-m-d') : NULL,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user