lundi 4 juillet 2016

Laravel5 console not registerring

As part of my Laravel 5.2 application, I would like to define a custom command for artisan, but my command doesn't appear in artisan list.

1). I created the command skeleton: artisan make:console --command=process:emails

2). I added a bit of test code to the handle() method of the new class:

<?php

namespace App\Console\Commands;

use App\CommunicationsQueue;
use Illuminate\Console\Command;

class ProcessEmailQueueCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'process:email';

    /**
     * The console command description.
     *
     * @var string
    */
    protected $description = 'Send all currently pending emails in the queue';

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

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        CommunicationsQueue::where('status', 'PENDING')->update(['status'=>'TEST']);

        $this->info('The mails queue was successfully processed.');
    }
}

3). Then, I registerred the command in app/Console/Kernel.php:

protected $commands = [
    Commands\ProcessEmailQueueCommand::class,
];

What am I missing here? I'm sure it's something incredibly simple, but I'm not seeing it.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire