1つのコントローラーに複数のメソッドがあり、それを各々のタイミングで実行させたい場合、コマンドクラスに記述するのは、同じタイミングのものだけと決まっているのでしょうか。
例えば下記のように、一つのコマンドクラスに複数のメソッドを指定しても選別できないような気がしています。
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use app\Http\Controllers\EventSetController; class EventCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'command:event_1'; protected $signature = 'command:event_2'; /** * The console command description. * * @var string */ protected $description = '毎月のイベント'; protected $description = '毎週のイベント'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { EventSetController::event_1(); EventSetController::event_2(); } }
また、kernel.phpも、下記のような複数指定を単純に列挙しただけではうまくいかないような気がしています。
class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. * * @var array */ protected $commands = [ \App\Console\Commands\EventCommand::class, ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule ->command('command:event_1') ->withoutOverlapping() ->monthly(); $schedule ->command('command:event_2') ->withoutOverlapping() ->weekly(); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } }
すぐ調べれば出てくると思いましたが、自分の理解も足りず分からないままであります。
ご教授いただければ幸いですm(__)m
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。