From a320c0d0debf2d191519011d540cc43dbbbb9b4b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 30 Apr 2017 12:49:45 +0300 Subject: [PATCH] Wrong date sort order for tasks #1455 --- app/Ninja/Repositories/TaskRepository.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index e0dbc298ad24..5bf89158af54 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -7,6 +7,7 @@ use App\Models\Project; use App\Models\Task; use Auth; use Session; +use DB; class TaskRepository extends BaseRepository { @@ -17,7 +18,7 @@ class TaskRepository extends BaseRepository 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') @@ -30,7 +31,7 @@ class TaskRepository extends BaseRepository ->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', @@ -49,7 +50,7 @@ class TaskRepository extends BaseRepository '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',