如何从(调度程序)laravel5中的kernal.php调用控制器(方法)

时间:2015-09-22 11:51:49

标签: php cron laravel-5 scheduler

控制器文件

namespace App\Http\Controllers;
use App\Repositories\CampaignpostRepository;
use App\Models\User;
use Illuminate\Exception\Handler;
use DB;
class CampaignpostController extends Controller {

    protected $campaign_gestion;
    /**
     * Store a new user.
     *
     * @param  Request  $request
     * @return Response
     */

    public function __construct(
    CampaignpostRepository $campaign_gestion)
   {
       $this->campaign_gestion = $campaign_gestion;
   }

     public function index()
    {
    }

kernal.php

protected function schedule(Schedule $schedule)
 {
//  $schedule->command('inspire')
//     ->hourly();
                $schedule->command('CampaignpostController@index')->everyMinute();
 }

我需要从kernal.php文件中调用CampaignpostController 我该如何调用CampaignpostController。

1 个答案:

答案 0 :(得分:0)

试试这个

protected function schedule(Schedule $schedule)
 {
   $schedule->call('CampaignpostController@index')->everyMinute();
 }