This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

yeoman
yeoman

hello guys anyone could help me please, i am trying to make a component which will output some html by reading from modal "Word" by picking one entery randomly. so far i am able to make the part of randomly picking up and outputting using default.html via components onRun() method like this


    public function onRun()
    {
        $this->test = 'Running Word of the day in Cro job ...';
        $this->words = $this->loadWords();
    }
    /**
     * Function to load words from the Word Model
     * @use Yeoman\Wordbank\Models\Word 
     * @return Array [description]
     */
    public function loadWords()
    { 
        $query = Word::orderBy(DB::raw('RAND()'))->first();
        return $query;
        // return wordofday::renderPartial('word.htm');
    }

i tried to setup cron job in plugin.php using registerSchedule method. I tried to call by making static method from component in cron job and used sendOutputTo( storage_path('app/testing.txt') ) to see if cron job will out put something but all in vain. I setup cron job in my virtual machine as well and i am using this command php /var//www/public/artisan schedule:run to see if something will output but i also see in response of the command "Running scheduled command: Closure" but nothing in app/testing.txt file. My plugin.php is containing this

    public function registerSchedule($schedule)
    {
        // $schedule->call('Yeoman\Wordbank\Components\Wordofday@loadWords')
        // ->everyMinute()
        // ->sendOutPutTo( storage_path('app/testing.txt') );
        // 
        $schedule->call(function() {
            // wordofday::loadWords();
            $wordofday = new wordofday;
            $wordofday->loadWords();
            // $Wordofday = new Wordofday;
            // $Wordofday->loadWords();
        })
        ->everyMinute()
        ->sendOutputTo( storage_path('app/testing.txt') );
    }

anyone could give me direction or idea how to make a component which will daily pick a random entry from my "word modal" and output it on daily bases. I don't know where to go from here....:/

Parsec
Parsec

I've had issues with ->everyMinute() myself and I had success with the same code with every other timeframe I've tried. Perhaps it's a bug or missing Larvel code

yeoman
yeoman

what do you recommend me to do? i am using sctochbox on virtual machine and really desperate to find a solution. :/ Although i remember doing ticket system project on laravel for testing purposes and there was no error, i didn't had any cron jobs in that laravel project but it was working fine.

Last updated

carl0s
carl0s

Late reply, but as the docs say, you can't use sendOutputTo or sendEmailTo if you are doing $schedule->call()

you can only do that with $schedule->command()

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.