How to allow models with belongsToMany relationship to be searchable using datatables?

  datatables, javascript, laravel, php

I have the following model that has a belongsToMany relationship:

class Sale extends Model
    public function items()
        return $this->belongsToMany(Item::class)->select(
            [DB::raw("COUNT(*) as quantity"), 
            DB::raw("CONCAT('(', GROUP_CONCAT(serial_number SEPARATOR ', '), ')') AS serial_number"),
        ->join('item_purchase', 'item_sale.item_purchase_id', '=', '')
        ->orderBy('', 'ASC')
        ->groupBy('item_sale.item_id', 'item_sale.sale_id');

and on my controller

public function demo(Request $request)
        if ($request->ajax()) {
            $data = Sale::with(['branch', 'items', 'customer', 'user'])->select(['*']);

            return Datatables::of($data)

and on my jquery

        "processing": true,
        "serverSide": true,
        "ajax": "{{ route('rma.demo') }}",
        "columns": [
            {data: 'created_at'},
            {data: 'branch.address'},
            {data: 'sale_number'},
            {data: 'items'}

My problem is i cant seem to search for the ‘items’ in my view when i use the searchbox of datatables, it gives out an error. is this even possible to do using datatables?

Source: Ask PHP