Jobs refactor
This commit is contained in:
parent
dc22123dbb
commit
edf030bb18
2 changed files with 13 additions and 12 deletions
|
|
@ -19,9 +19,9 @@ class GamesStatusUpdate
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\News> */
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
||||
$gamesListToUnPublish = Game::query()
|
||||
->where('unpublish_at', '<=', Carbon::now()->toDateTime())
|
||||
->where('unpublish_at', '<=', Carbon::now())
|
||||
->whereNotNull('unpublish_at')
|
||||
->where('published', true)->get();
|
||||
Log::debug(__CLASS__ . " games to unpublish " . $gamesListToUnPublish->count());
|
||||
|
|
@ -31,18 +31,19 @@ class GamesStatusUpdate
|
|||
$game->published = false;
|
||||
$game->saveOrFail();
|
||||
}
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\> */
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\Game> */
|
||||
$gamesListToPublish = Game::query()
|
||||
->where('publish_at', '<=', Carbon::now()->toDateTime())
|
||||
->where('publish_at', '<=', Carbon::now())
|
||||
->whereNotNull('publish_at')
|
||||
->where('published', false)->get();
|
||||
Log::debug(__CLASS__ . " games to publish " . $gamesListToPublish->count());
|
||||
// Unpublish all game with no date because only 1 game can be published.
|
||||
if ($gamesListToPublish->count()) {
|
||||
Game::query()->where('published', true)->each(function (Game $game) {
|
||||
$game->published = false;
|
||||
$game->saveOrFail();
|
||||
});
|
||||
Game::query()->where('published', true)
|
||||
->each(function (Game $game) {
|
||||
$game->published = false;
|
||||
$game->saveOrFail();
|
||||
});
|
||||
}
|
||||
foreach ($gamesListToPublish as $game) {
|
||||
$game->publish_at = null;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ class NewsStatusUpdate
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\News> */
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
||||
$newsListToPublish = News::query()
|
||||
->where('publish_at', '<=', Carbon::now()->toDateTime())
|
||||
->where('publish_at', '<=', Carbon::now())
|
||||
->whereNotNull('publish_at')
|
||||
->where('published', false)->get();
|
||||
Log::debug(__CLASS__ . " news to publish " . $newsListToPublish->count());
|
||||
|
|
@ -30,9 +30,9 @@ class NewsStatusUpdate
|
|||
$news->published = true;
|
||||
$news->saveOrFail();
|
||||
}
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\News> */
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News> */
|
||||
$newsListToUnPublish = News::query()
|
||||
->where('unpublish_at', '<=', Carbon::now()->toDateTime())
|
||||
->where('unpublish_at', '<=', Carbon::now())
|
||||
->whereNotNull('unpublish_at')
|
||||
->where('published', true)->get();
|
||||
Log::debug(__CLASS__ . " news to unpublish " . $newsListToPublish->count());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue