Skip to content

Commit

Permalink
Merge pull request #2 from laravel-enso/fixes/fixesTimePsql
Browse files Browse the repository at this point in the history
fixes time in psql
  • Loading branch information
raftx24 committed Nov 26, 2020
2 parents af5ed11 + 69becdb commit f294837
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Models/Task.php
Expand Up @@ -3,6 +3,7 @@
namespace LaravelEnso\Tasks\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Auth;
Expand All @@ -14,7 +15,7 @@

class Task extends Model
{
use TableCache, CreatedBy, UpdatedBy;
use TableCache, HasFactory, CreatedBy, UpdatedBy;

protected $guarded = ['id'];

Expand Down
10 changes: 7 additions & 3 deletions src/Tables/Builders/TaskTable.php
Expand Up @@ -2,6 +2,7 @@

namespace LaravelEnso\Tasks\Tables\Builders;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use LaravelEnso\Helpers\Services\Obj;
Expand All @@ -16,14 +17,17 @@ class TaskTable implements Table, CustomFilter, ConditionalActions

public function query(): Builder
{
$now = Carbon::now();
$overdue = "completed = true and reminder >= '{$now}'";

return Task::visible()
->with('createdBy.avatar', 'createdBy.person')
->with('allocatedTo.avatar', 'allocatedTo.person')
->selectRaw('
->selectRaw("
tasks.id, tasks.name, tasks.description, tasks.flag, tasks.completed,
tasks.allocated_to, tasks.reminder, tasks.reminder as rawReminder,
created_by, created_at, IF(completed, 0, reminder < CURRENT_TIME()) as overdue
');
created_by, created_at, {$overdue} as overdue
");
}

public function templatePath(): string
Expand Down

0 comments on commit f294837

Please sign in to comment.