osb/app/Console/Commands/ServiceList.php

60 lines
1.1 KiB
PHP
Raw Normal View History

2020-02-10 11:07:46 +00:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Models\Service;
class ServiceList extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'service:list';
/**
* The console command description.
*
* @var string
*/
protected $description = 'List all services';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
DB::listen(function($query) {
Log::debug('- SQL',['sql'=>$query->sql,'binding'=>$query->bindings]);
});
foreach (Service::active()->get() as $o) {
$this->info(sprintf('|%10s|%-6s|%-20s|%-50s|%8s|%14s|%10s|',
$o->sid,
$o->product->category,
$o->product_name,
$o->name_short,
$o->active ? 'active' : 'inactive',
$o->status,
$o->invoice_next ? $o->invoice_next : NULL,
));
}
}
}