2015-02-08 37 views
2

好了,所以我已經安裝了https://github.com/liebig/cron 一切與這工作等等克龍在laravel(使用https://github.com/liebig/cron)

我有,雖然實現這個麻煩。 在我laravel /程序/啓動/ global.php

我把這個:

Event::listen('cron.collectJobs', function() { 
    Cron::add('deposit_reminder', '* * * * *', function() { 
     foreach (Site::where('org_id', Auth::user()->organization->id)->get() as $site){  
      foreach (Game::get() as $game) {  
     ALOT MORE CORE IS HERE thats not really relevant to see 

     Cron::setEnableJob('deposit_reminder'); 

     return null; 
    }); 
}); 

有了這個代碼在global.php我認爲正在發生的事情是,我想用戶驗證::用戶() - >等...但在這一點上登錄將不會被解僱,因爲這是在laravel啓動我想?

我試圖把這個代碼放到routes.php中,並且在成功登錄後,這個cron作業會被創建,但是當我這樣做的時候它似乎沒有爲cronjob創建作業......有沒有人有任何建議?

回答

0

我想出瞭如何做,而不是使用Auth :: user,只需要循環遍歷用戶模型,所以做一個User :: get(),並且可以使用它循環遍歷每個用戶併發送一個基於數據庫中的標準的電子郵件。

完美無瑕地工作,我希望這可以幫助別人在未來。