31 lines
816 B
PHP
31 lines
816 B
PHP
<?php
|
|
|
|
namespace App\Domains\Real\Commands\Sync;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Console\Command as BaseCommand;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
class Command extends BaseCommand
|
|
{
|
|
protected function getDateTime()
|
|
{
|
|
if ($month = $this->argument('month')) {
|
|
if (!preg_match('/\d{4}-\d{1,2}/', $month)) {
|
|
throw new \App\Exceptions\InvalidArgumentException('请输入正确的年月 #示例: 2018-10');
|
|
}
|
|
|
|
return Carbon::parse($month)->startOfMonth();
|
|
}
|
|
|
|
return Carbon::now()->startOfMonth()->subMonth();
|
|
}
|
|
|
|
protected function getArguments()
|
|
{
|
|
return [
|
|
['month', InputArgument::OPTIONAL, '要同步的数据月份,默认上个月 #示例: 2018-10'],
|
|
];
|
|
}
|
|
}
|