mivita/app/Console/Commands/BusinessStore.php
2022-07-29 18:18:05 +02:00

78 lines
2.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\Setting;
use Illuminate\Console\Command;
use App\Cron\BusinessUsersStore;
class BusinessStore extends Command
{
/**
* php artisan business:store month year
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'business:store {month} {year}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create Business Structur and UserDetails';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$day = (int) Setting::getContentBySlug('day-exectute-business-structur');
$this->info('RUN Command BusinessStore on Day '. $day);
$timeStart = microtime(true);
$this->info('RUN Command BusinessStore');
$month = $this->argument('month');
$year = $this->argument('year');
if(!$month || !$year){
$this->info('need arguments month & year');
return 0;
}
//$this->info('month: '.$month.' year:'.$year);
for($i = 1; $i<=6; $i++){
$month = $i;
$this->info('month: '.$month.' year:'.$year);
$businessUsersStore = new BusinessUsersStore($month, $year);
$businessUsersStore->storeUserBusinessStructure();
$businessUsersStore->storeBusinessUsersDetail();
$bool = $businessUsersStore->storeBusinessCompleted();
$diff = microtime(true) - $timeStart;
$sec = intval($diff);
$micro = $diff - $sec;
$this->info('BusinessStore: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
}
//$this->info('END Command BusinessStore: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
// \Log::info('Cron is running');
//return 0;
}
}