that code works well but when search
throw exception: "Cardinality violation: 1241 Operand should contain 1 column(s) .. "
$foo = '';
foreach (Store::getList() as $key => $value) {
$foo .= "(SELECT
warehouses.quantity
FROM
warehouses
INNER JOIN items ON warehouses.item_id = items.id
INNER JOIN stores ON warehouses.store_id = stores.id
where
warehouses.item_id = items.id
AND
stores.id = $key) ,";
}
// remove last , to correct syntax
$foo = substr($foo, 0, -1);
$boo = DB::table("warehouses")
->join('items','warehouses.item_id','=','items.id')
->select(
'items.id as itemId',
'items.item_code as itemCode',
'items.name as itemName',
DB::raw($foo)
)
->distinct();
return Datatables::of($boo)
->remove_column('itemId')
->make();
I think here is the issue
Bllim\Datatables\Datatables.php
private function count($count = 'count_all')
{
//Get columns to temp var.
$query = $this->query_type == 'eloquent' ? $this->query->getQuery() : $this->query;
//Count the number of rows in the select
$this->$count = DB::table(DB::raw('('.$query->toSql().') AS count_row_table'))
->setBindings($query->getBindings())->count();
}
that code works well but when search throw exception: "Cardinality violation: 1241 Operand should contain 1 column(s) .. "
I think here is the issue Bllim\Datatables\Datatables.php