I'm using server side, and I have two fields, demand_number and demand_year, and I like to display this fields in one field like a demand_number / demand_year ( 001 / 2019 )
How can I do this?
You can use accessor/mutator and add custom column
Try to create a custom column like demand_info in your frontend. And, on your controller, edit the column, like:
$datatables->editColumn('demand_info', function ($eloquent) {
return $eloquent->demand_number . '/' . $eloquent->demand_year;
});
If you need search by this fields, don't forget to filter the column, like:
$datatables->filterColumn('demand_info', function ($query, $keyword) {
$query->where('demand_number', 'like', $keyword)
->orWhere('demand_year', 'like', $keyword);
});
Warning: This codes was not tested.
Thanks @connectmalves works perfectly!
Most helpful comment
Try to create a custom column like
demand_infoin your frontend. And, on your controller, edit the column, like:If you need search by this fields, don't forget to filter the column, like:
Warning: This codes was not tested.