Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes time in psql #2

Merged
merged 4 commits into from Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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