<?php

namespace App\Services\Dashboard\Province\OperatorDialogues;

use App\Facades\DataTable\DataTableFacade;
use App\Models\OperatorDialogue;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class DataTableService
{
    public function index(Request $request)
    {
        $query = DB::table('asteriskcdrdb.cdr')
            ->leftJoin('crm_db.operator_dialogues', 'asteriskcdrdb.cdr.uniqueid', '=', 'crm_db.operator_dialogues.cdr_unique_id')
            ->where('dst', '<>', '')
            ->where('lastapp', '=', 'Dial')
            ->where('duration', '>', 0)
            ->where('recordingfile', '<>', '');

        return DataTableFacade::run(
            $query,
            $request,
            allowedFilters: ['*'],
            allowedSortings: ['*'],
        );
    }
}
