You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm currently upgrading a laravel 6 project to laravel 8 I'm using yajra/laravel-datatables but facing always the same error:
Call to undefined method Illuminate\Database\Query\Builder::addColumn()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi folks,
i'm currently upgrading a laravel 6 project to laravel 8 I'm using yajra/laravel-datatables but facing always the same error:
Call to undefined method Illuminate\Database\Query\Builder::addColumn()
Can please someone help me?
Thanks in advance
This is my method that generates the json data:
` protected function getTickets($status, $request, bool $currentUser = false): JsonResponse
{
$datatable = TicketRepository::ticketsDatatableQuery($status, $request, $currentUser);
An this is my repository method:
`public static function ticketsDatatableQuery($status, $request, bool $currentUser = false)
{
$query = DB::table('tickets as t')
->select(
't.id',
't.ticket_id',
't.customer_type',
't.customer_id',
't.client',
't.subject',
't.subject_id',
't.date',
't.time',
't.deadline',
't.priority',
't.type',
't.status',
't.severity',
't.channel',
't.datacenter',
't.owner',
't.team_id',
't.autoclose',
't.is_read',
't.created_at',
't.updated_at',
's.shortname',
'u.first_name',
'u.last_name',
'c2.status as comment_status',
'c2.priority as comment_priority',
'c2.severity as comment_severity',
'c2.created_at as comment2_created_at',
'p.id as prospect_id',
'p.company_name',
'nt.name as team_name',
DB::raw("CONCAT_WS(' ', t.client, cc.companyname, CONCAT_WS(' ', cco.prename, cco.name)) as ticket_customer"),
'cc.companyname',
DB::raw("CONCAT_WS(' ', cco.prename, cco.name) as billing_contact"),
DB::raw("CONCAT_WS(' ', t.subject, s.shortname) as ticket_subject"),
DB::raw("CONCAT_WS(' ', u.first_name, u.last_name) as ticket_owner"),
DB::raw('MAX(c1.created_at) as comment1_created_at'),
DB::raw('COUNT(c1.id) as status_count')
)
->leftJoin('billing.CUSTOMERS AS c', function ($join) {
$join->on('t.customer_id', '=', 'c.customerid')
->where('t.customer_type', 'billing');
})
->leftJoin('billing.CUSTOMER_COMPANIES AS cc', 'c.companyid', '=', 'cc.companyid')
->leftJoinSub(DB::table('billing.CUSTOMER_HAS_CONTACTS AS chc')
->select('cc.prename', 'cc.name', 'chc.customerid', 'cc.contactid')
->join('billing.CUSTOMER_CONTACTS AS cc', function ($join) {
$join->on('chc.contactid', '=', 'cc.contactid')
->where('cc.contactid', DB::raw("(
SELECT MAX(cc2.contactid) as contactid
FROM billing.CUSTOMER_CONTACTS AS cc2
JOIN billing.CUSTOMER_HAS_CONTACTS AS chc2 ON cc2.contactid = chc2.contactid
WHERE cc2.typeid = '2' AND chc.customerid = chc2.customerid
GROUP BY chc2.customerid
)"));
}), 'cco', function ($join) {
$join->on('c.customerid', '=', 'cco.customerid');
})
->leftJoin('subjects as s', 't.subject_id', '=', 's.id')
->leftJoin('prospects as p', function ($join) {
$join->on('t.customer_id', '=', 'p.id')
->where('t.customer_type', 'sales');
})
->leftJoin('ticket_comments as c1', 't.id', '=', 'c1.ticket_id')
->leftJoin('ticket_comments as c2', 't.id', '=', 'c2.ticket_id')
->leftJoin('users as u', 't.owner', '=', 'u.id')
->leftJoin('noc_teams as nt', 't.team_id', '=', 'nt.id')
->when($currentUser, function ($q) use ($request) {
return $q->where('t.owner', $request->user_id);
}, function ($q) use ($request, $status) {
$user = User::find($request->user_id);
$role = DB::table('user_roles')
->join('roles as r', 'role_id', '=', 'r.id' )
->select('r.name')
->where('user_id', '=', Auth::user()->id)
->first();
Beta Was this translation helpful? Give feedback.
All reactions