File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
src/LiveControl/EloquentDataTable Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ If you are familiar with eloquent and would like to use it in combination with [
1010
1111### Step 2: Add DataTables javascript and set it up
1212For more information check out the [ datatables manual] ( http://datatables.net/manual/index ) .
13+ Make sure you have [ csrf requests] ( http://laravel.com/docs/master/routing#csrf-protection ) working with jquery ajax calls.
1314``` javascript
1415var table = $ (' #example' ).DataTable ({
1516 " processing" : true ,
Original file line number Diff line number Diff line change @@ -243,19 +243,19 @@ private function addAllFilter($search)
243243 {
244244 $ this ->builder = $ this ->builder ->where (
245245 function ($ query ) use ($ search ) {
246- foreach ($ this ->rawColumns as $ rawColumn ) {
247- $ query ->orWhere (new raw ( $ rawColumn ) , 'like ' , '% ' . $ search . '% ' );
246+ foreach ($ this ->columnNames as $ column ) {
247+ $ query ->orWhere ($ column , 'like ' , '% ' . $ search . '% ' );
248248 }
249249 }
250250 );
251251 }
252252
253253 private function addColumnFilters ()
254254 {
255- foreach ($ this ->rawColumns as $ i => $ rawColumn ) {
255+ foreach ($ this ->columnNames as $ i => $ column ) {
256256 if ( static ::$ versionTransformer ->isColumnSearched ($ i ) ) {
257257 $ this ->builder ->where (
258- new raw ( $ rawColumn ) ,
258+ $ column ,
259259 'like ' ,
260260 '% ' . static ::$ versionTransformer ->getColumnSearchValue ($ i ) . '% '
261261 );
@@ -267,9 +267,9 @@ protected function addOrderBy()
267267 {
268268 if ( static ::$ versionTransformer ->isOrdered () ) {
269269 foreach (static ::$ versionTransformer ->getOrderedColumns () as $ index => $ direction ) {
270- if ( isset ($ this ->rawColumns [$ index ]) ) {
270+ if ( isset ($ this ->columnNames [$ index ]) ) {
271271 $ this ->builder ->orderBy (
272- new raw ( $ this ->rawColumns [$ index ]) ,
272+ $ this ->columnNames [$ index ],
273273 $ direction
274274 );
275275 }
You can’t perform that action at this time.
0 commit comments