我已使用yajra/laravel-datatables創建數據網格列表。按照要求我使用聯接來檢索信息。yajra/laravel-datatables搜索未與laravel 5.4
這裏是加入代碼
$inquiryInvoice = DB::table('inquiry_invoice')->select('inquiry_invoice.*',DB::raw('CONCAT(inquiry_personal.first_name, " ", inquiry_personal.middle_name, " ", inquiry_personal.last_name) AS full_name'), 'inquiry_personal.id as inquiry_personal_id','branches.branch_name',DB::raw('CONCAT(users.first_name, " ", users.last_name) AS user_full_name'), DB::raw('CONCAT(counselor.first_name, " ", counselor.last_name) AS counselor_full_name'), 'inquiry_counselor.user_id as inquiry_counselor_user_id','inquiry_master.workflow_id',DB::raw(' "invoice" AS type'))
->join('inquiry_master', 'inquiry_master.id', '=', 'inquiry_invoice.inquiry_id')
->join('inquiry_personal', 'inquiry_master.id', '=', 'inquiry_personal.inquiry_id')
->join('branches', 'inquiry_master.branch_id', '=', 'branches.id')
->join('users', 'inquiry_master.user_id', '=', 'users.id')
->leftJoin('inquiry_counselor', 'inquiry_master.id', '=', 'inquiry_counselor.inquiry_id')
->leftJoin('users as counselor', 'inquiry_counselor.user_id', '=', 'counselor.id');
這裏是分配Datatables
return Datatables::of($inquiryInvoice)
->escapeColumns([])
->make(true);
這裏代碼jQuery代碼
$dataTable = $('#data-table').DataTable({
processing: true,
serverSide: true,
Filter: true,
url:'{!! url("transaction_any_data") !!}',
columns: [
{ data: 'full_name', name: 'full_name' },
{ data: 'branch_name', name: 'branch_name' },
{ data: 'user_full_name', name: 'user_full_name' },
{ data: 'counselor_full_name', name: 'counselor_full_name' }
]
});
現在,當我試圖尋找的東西它給我警報與錯誤 下面是一個錯誤信息,
現在我想知道,
我怎麼能快速查找使用JOIN
和CONCAT
列?
有沒有做到這一點的具體方法是什麼?
請給我建議最好的辦法......
這有什麼好做的DataTable。您的SQL查詢中有錯誤,就像錯誤消息所示。 – Jerodev
@Jerodev,它不是SQL錯誤,因爲當我運行mysql查詢它運作良好,並返回結果。問題是數據表數據庫表的列上搜索,而不是在concated列 –