【发布时间】:2016-08-19 21:42:11
【问题描述】:
我是 laravel 的新手。我试图在我的测试项目中创建一个自定义的artisan 命令来创建表。我遵循this link 但我的命令不在工匠列表中。事件我尝试了该链接中给出的相同示例,但它也不起作用。我不知道为什么会这样。
我做到了:
1) 运行此命令php artisan make:console SendEmails
2) 将完整的类代码放入app/Console/Commands/SendEmails.php文件中
<?php
namespace App\Console\Commands;
use App\User;
use App\DripEmailer;
use Illuminate\Console\Command;
class SendEmails extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'email:send {user}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send drip e-mails to a user';
/**
* The drip e-mail service.
*
* @var DripEmailer
*/
protected $drip;
/**
* Create a new command instance.
*
* @param DripEmailer $drip
* @return void
*/
public function __construct(DripEmailer $drip)
{
parent::__construct();
$this->drip = $drip;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->drip->send(User::find($this->argument('user')));
}
}
请帮助我,让我知道我做错了什么。
【问题讨论】:
-
你应该删除
javascript标签,因为它与这个问题无关。
标签: php laravel laravel-5 laravel-artisan