2017-02-01 5 views
3

これは真っ直ぐ前方にあるはずですが、なぜそれが動作していないのかわかりません。私はlaravelのコマンドを作成して、ユーザーの誕生日にbirtday電子メールリマインダを送信しています。Laravel多すぎる引数、期待される引数 "command"スケジューリング中

すべてが正常に動作し、スケジュール機能がトリガされますが、これは私のコマンド

<?php 

namespace App\Console\Commands; 

use Illuminate\Console\Command; 
use App\User; 
class SendBirthdayReminderEmail extends Command 
{ 
    /** 
    * The name and signature of the console command. 
    * 
    * @var string 
    */ 
    protected $signature = 'email:birthday'; 

    /** 
    * The console command description. 
    * 
    * @var string 
    */ 
    protected $description = 'Email users a birthday Reminder message'; 

    /** 
    * Create a new command instance. 
    * 
    * @return void 
    */ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    /** 
    * Execute the console command. 
    * 
    * @return mixed 
    */ 
    public function handle() 
    { 

    $users = User::whereMonth('dob', '=', date('m'))->whereDay('dob', '=', date('d'))->get(); 
    foreach($users as $user) { 
     Mail::queue('emails.birthday', ['user' => $user], function ($mail) use ($user) { 
      $mail->to($user['email']) 
       ->from('[email protected]', 'Company') 
       ->subject('Happy Birthday!'); 
     }); 

    } 

    $this->info('Birthday messages sent successfully!'); 

    } 
} 

ある

[Symfony\Component\Console\Exception\RuntimeException] 
    Too many arguments, expected arguments "command". 

エラーが付属し、これが私のkernel.phpファイルです

<?php 

namespace App\Console; 

use Illuminate\Console\Scheduling\Schedule; 
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; 

class Kernel extends ConsoleKernel 
{ 
    /** 
    * The Artisan commands provided by your application. 
    * 
    * @var array 
    */ 
    protected $commands = [ 
    Commands\SendBirthdayReminderEmail::class 
    ]; 

    /** 
    * Define the application's command schedule. 
    * 
    * @param \Illuminate\Console\Scheduling\Schedule $schedule 
    * @return void 
    */ 
    protected function schedule(Schedule $schedule) 
    { 


     $schedule->command('email:birthday')->dailyAt('13:00')->timezone('Africa/Dar_es_Salaam'); 
    } 

    /** 
    * Register the Closure based commands for the application. 
    * 
    * @return void 
    */ 
    protected function commands() 
    { 
     require base_path('routes/console.php'); 
    } 
} 

助けていただければ幸いです。 runメソッド:私は解決策を見つけた

+0

おそらく、command()とdailyAt()の間の二重矢印( ' - > - ')ですか? – Sebastian

+0

ごめんなさい... –

+0

btwあなたはその親を呼び出すだけなので、 '__construct()'を削除することができます。それがなければ、親はとにかく呼ばれます。 ;-) – delboy1978uk

答えて

1

:-)おかげで、

/opt/php70/bin/php /home/sitename/public_html/artisan schedule:run >/dev/null 2>&1 

は当初、私はスケジュールの後に1を持っていました。以下のように

/opt/php70/bin/php /home/sitename/public_html/artisan schedule:run 1 >/dev/null 2>&1 
0

あなたのコードはすべて見栄えが良いです。 はあなたのルートフォルダのパスに到達した後

php artisan schedule:run 

以下のように単純にしようとしています。

関連する問題