背景介绍:我是一个 Laravel 5 的新手,但我在过去的项目中使用过 Laravel 4。
在 Laravel 4 中,我只需在 Artisan 命令中直接调用模型即可。但现在,我该如何在 Artisan 命令中调用模型?以下是我的当前代码:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\sampleModel as sampleModel;
class testCommand extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'test';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
sampleModel::sampleMethod();
}
}