Skip to content

Commit

Permalink
Wrong date sort order for tasks #1455
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Apr 30, 2017
1 parent a28b63c commit a320c0d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Ninja/Repositories/TaskRepository.php
Expand Up @@ -7,6 +7,7 @@
use App\Models\Task;
use Auth;
use Session;
use DB;

class TaskRepository extends BaseRepository
{
Expand All @@ -17,7 +18,7 @@ public function getClassName()

public function find($clientPublicId = null, $filter = null)
{
$query = \DB::table('tasks')
$query = DB::table('tasks')
->leftJoin('clients', 'tasks.client_id', '=', 'clients.id')
->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id')
->leftJoin('invoices', 'invoices.id', '=', 'tasks.invoice_id')
Expand All @@ -30,7 +31,7 @@ public function find($clientPublicId = null, $filter = null)
->where('contacts.deleted_at', '=', null)
->select(
'tasks.public_id',
\DB::raw("COALESCE(NULLIF(clients.name,''), NULLIF(CONCAT(contacts.first_name, ' ', contacts.last_name),''), NULLIF(contacts.email,'')) client_name"),
DB::raw("COALESCE(NULLIF(clients.name,''), NULLIF(CONCAT(contacts.first_name, ' ', contacts.last_name),''), NULLIF(contacts.email,'')) client_name"),
'clients.public_id as client_public_id',
'clients.user_id as client_user_id',
'contacts.first_name',
Expand All @@ -49,7 +50,7 @@ public function find($clientPublicId = null, $filter = null)
'tasks.time_log',
'tasks.time_log as duration',
'tasks.created_at',
'tasks.created_at as date',
DB::raw("SUBSTRING(time_log, 3, 10) date"),
'tasks.user_id',
'projects.name as project',
'projects.public_id as project_public_id',
Expand Down

0 comments on commit a320c0d

Please sign in to comment.