Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
API updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Aug 24, 2018
1 parent cb04fb7 commit 6b4a68d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ public function all()
{
$query = $this->model;

if (Schema::hasColumn(str_plural($this->modelName), 'is_published')) {
$query = $query->where('is_published', true);
}

if (Schema::hasColumn(str_plural($this->modelName), 'published_at')) {
$query = $query->where('is_published', 1)
->where('published_at', '<=', Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s'));
$query = $query->where('published_at', '<=', Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s'));
}

if (Schema::hasColumn(str_plural($this->modelName), 'finished_at')) {
$query = $query->where('finished_at', '>=', Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s'));
}

return $query
Expand Down

0 comments on commit 6b4a68d

Please sign in to comment.