Beispiel #1
0
 /**
  * Retrieve datatables raw data
  * 
  * @return array
  */
 public function getRaw()
 {
     $dtDataProvider = $this->dtDataProvider;
     $draw = $this->dtParamProvider->getLastDraw() + 1;
     $requested = $this->dtParamProvider->getColumns();
     $available = $dtDataProvider->dtGetAvailableColumns();
     // queryable columns
     // this columns is used perform query
     $queryableColumns = $this->mapQueryableColumn($available, $requested);
     $search = $this->dtParamProvider->getSearch();
     $start = $this->dtParamProvider->getStart();
     $length = $this->dtParamProvider->getLength();
     $order = $this->dtParamProvider->getOrder();
     // get total records
     $recordsTotal = $dtDataProvider->dtCount();
     // perform filter
     $dtDataProvider = $dtDataProvider->dtPerformColumnFilter($queryableColumns)->dtPerformGlobalFilter($queryableColumns, $search);
     // get filtered record
     $recordsFiltered = $dtDataProvider->dtCount();
     // get data after paginate and order
     $data = $dtDataProvider->dtPaginate($start, $length)->dtOrder($order, $queryableColumns)->dtGet($queryableColumns);
     // Apply custom columns and custom values to data
     $data = $this->serveData($available, $requested, $data);
     return compact('draw', 'data', 'recordsTotal', 'recordsFiltered');
 }
Beispiel #2
0
 function it_can_modify_column_value(DTParamProvider $dtParamProvider, DTDataProvider $dtDataProvider)
 {
     $params = $this->get_params();
     $results = $this->get_data_result();
     $expected = $this->get_expected();
     foreach ($expected['data'] as $key => $value) {
         $expected['data'][$key]['col.1'] .= '-modified';
     }
     $dtParamProvider->getLastDraw()->shouldBeCalled()->willReturn(1);
     $dtParamProvider->getColumns()->shouldBeCalled()->willReturn($params['columns']);
     $dtDataProvider->dtGetAvailableColumns()->shouldBeCalled()->willReturn(['col.1', 'col.2', 'col.3']);
     $dtParamProvider->getSearch()->shouldBeCalled()->willReturn($params['search']);
     $dtParamProvider->getStart()->shouldBeCalled()->willReturn(1);
     $dtParamProvider->getLength()->shouldBeCalled()->willReturn(10);
     $dtParamProvider->getOrder()->shouldBeCalled()->willReturn($params['order']);
     $dtDataProvider->dtCount()->shouldBeCalled()->willReturn(1000);
     $dtDataProvider->dtPerformColumnFilter($params['columns'])->shouldBeCalled()->willReturn($dtDataProvider);
     $dtDataProvider->dtPerformGlobalFilter($params['columns'], $params['search'])->shouldBeCalled()->willReturn($dtDataProvider);
     $dtDataProvider->dtPaginate(1, 10)->shouldBeCalled()->willReturn($dtDataProvider);
     $dtDataProvider->dtOrder($params['order'], $params['columns'])->shouldBeCalled()->willReturn($dtDataProvider);
     $dtDataProvider->dtGet($params['columns'])->shouldBeCalled()->willReturn($results);
     $this->setDTDataProvider($dtDataProvider)->setValue('col.1', function ($data) {
         return $data['col.1'] . '-modified';
     })->getRaw()->shouldEqual($expected);
 }