Laravel Too many arguments, expected command arguments when planning

This should be directed forward, but I do not know why it does not work. I am creating a team in laravel to send birtday email reminders to birtday user.

Everything works fine, and the schedule function starts, but it arrives with an error

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

This is my team

<?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('info@XXXXXX.com', 'Company')
                ->subject('Happy Birthday!');
        });

     }

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

    }
}

And this is my kernel.php file

<?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 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');
    }
}

Any help would be appreciated. Thank: -)

+7
source share
3 answers

I found a solution

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

I initially had 1 after the schedule: run the method. As below

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

Your code looks good. You tried just as below

php artisan schedule:run

.

+1

, ..

I am trying to create a generator command like make: model .. but this time make: helper ... if I specify the name name attribute → if I don't - error

0
source

Source: https://habr.com/ru/post/1668490/


All Articles