Wrong date sort order for tasks #1455

This commit is contained in:
Hillel Coren 2017-04-30 12:49:45 +03:00
parent a28b63ce0f
commit a320c0d0de

View File

@ -7,6 +7,7 @@ use App\Models\Project;
use App\Models\Task; use App\Models\Task;
use Auth; use Auth;
use Session; use Session;
use DB;
class TaskRepository extends BaseRepository class TaskRepository extends BaseRepository
{ {
@ -17,7 +18,7 @@ class TaskRepository extends BaseRepository
public function find($clientPublicId = null, $filter = null) public function find($clientPublicId = null, $filter = null)
{ {
$query = \DB::table('tasks') $query = DB::table('tasks')
->leftJoin('clients', 'tasks.client_id', '=', 'clients.id') ->leftJoin('clients', 'tasks.client_id', '=', 'clients.id')
->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id') ->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id')
->leftJoin('invoices', 'invoices.id', '=', 'tasks.invoice_id') ->leftJoin('invoices', 'invoices.id', '=', 'tasks.invoice_id')
@ -30,7 +31,7 @@ class TaskRepository extends BaseRepository
->where('contacts.deleted_at', '=', null) ->where('contacts.deleted_at', '=', null)
->select( ->select(
'tasks.public_id', '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.public_id as client_public_id',
'clients.user_id as client_user_id', 'clients.user_id as client_user_id',
'contacts.first_name', 'contacts.first_name',
@ -49,7 +50,7 @@ class TaskRepository extends BaseRepository
'tasks.time_log', 'tasks.time_log',
'tasks.time_log as duration', 'tasks.time_log as duration',
'tasks.created_at', 'tasks.created_at',
'tasks.created_at as date', DB::raw("SUBSTRING(time_log, 3, 10) date"),
'tasks.user_id', 'tasks.user_id',
'projects.name as project', 'projects.name as project',
'projects.public_id as project_public_id', 'projects.public_id as project_public_id',