在$signature的任务明后添加 参数 {type} 添加 type 的默认值 {type=0} :
protected $signature = 'SynchroCount {object=0} {type=0}';
接收type值 :$this->argument('type');
手动执行命令:php artisan SynchroCount 1 2
<?php
namespace App\Console\Commands;
use App\Models\Entity\Bubbling;
use App\Models\Entity\Comment;
use App\Models\Entity\Likes;
use Illuminate\Console\Command;
class SynchroCount extends Command
{
/**
* The name and signature of the console command.
*
* @var Int
*/
protected $signature = 'SynchroCount {object=0} {type=0}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Synchro Count';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
$object = $this->argument('object');
$type = $this->argument('type');
print_r( $object . '-' . $type );
}
}