Comments (1)
https://yajrabox.com/docs/laravel-datatables/master/response-fractal
When using tranformer, all response manipulations must be done via transformer. Thus
addColumn
,editColumn
,removeColumn
,setRowAttr
,setClassAttr
, etc... should be avoided when using fractal.https://yajrabox.com/docs/laravel-datatables/master/row-options
The methods above are extremely useful, why is fractal preventing their use?
Because with fractal it self you can return data on each row, than what's the point of adding columns with add Column or remove Column if you can change using fractal manually on the laravel transformer (TL:DR, it's redundant)?
Last time I also think I want to add Column but after learn about it's change the return as free as I want, I left addColumn if not needed.
eg :
user
- id
- username
- branch
- city
- name
in transformer fractal you only need to
use DataTables;
use App\User;
Route::get('user-data', function() {
$model = User::query();
return DataTables::eloquent($model)
->setTransformer(function($item){
return [
'id' => (int) $item->id,
'name' => $item->name,
'branch_city' => $item->branch . $item->city,
];
})
->toJson();
});
Other than like this
use DataTables;
use App\User;
Route::get('user-data', function() {
$model = User::query();
return DataTables::eloquent($model)
->setTransformer(function($item){
return [
'id' => (int) $item->id,
'name' => $item->name,
];
})
->addColumn('branch_city', function(User $user) {
return $item->branch . $item->city;
})
->toJson();
});
from laravel-datatables-fractal.
Related Issues (12)
- BadMethodCallException - Method setTransformer does not exist. HOT 3
- fractal and action buttons HOT 1
- Method setTransformer does not exist HOT 3
- Searching return empty HOT 1
- install failed HOT 1
- Not supporting Laravel-DataTables-oracle [9.0] HOT 2
- Installing Error by Composer require HOT 2
- Not supported for laravel 9 HOT 2
- Datatable return same values in different pages
- quick installation typo HOT 1
- BadMethodCallException Method where does not exist. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-datatables-fractal.