public function getRefreshTweets() { $tweet = UpcomingTweet::where('end', '<', date('Y-m-d H:i:s'))->first(); if ($tweet != null) { $tweet->delete(); $newTweet = UpcomingTweet::orderBy('id', 'asc')->first(); $newTweet->end = date('Y-m-d H:i:s', strtotime('+ 1 hour')); $newTweet->save(); } return redirect()->route('admin'); }
/** * Execute the console command. * * @return mixed */ public function handle() { \Log::alert('Refresh tweets'); $tweet = UpcomingTweet::where('end', '<', date('Y-m-d H:i:s'))->first(); if ($tweet != null) { $tweet->delete(); $newTweet = UpcomingTweet::orderBy('id', 'asc')->first(); $newTweet->end = date('Y-m-d H:i:s', strtotime('+ 1 hour')); $newTweet->save(); } }