In this my case in yajara table return row column. i add one extra column if condition true . can i make it?
Here my code
`return DataTables::of($data)
if(Here my condition statment){
->addColumn('show_date', function ($row) {
return '<span class="w-full">' . $row->name . '</span>';
})
}
->addColumn('show_date', function ($row) {
return '<span class="w-full">' . $row->show_date . '</span>';
})
->addColumn('action', function ($row) {
$viewUrl = route('', ['date' => $row->show_date]);
$buttons = '';
return $buttons;
})
if(){
->rawColumns(['show_date', 'action'])
}else{
->rawColumns(['name','show_date', 'action'])
}`your text`
->make(true);`
In above can , in yajara table return statement if condition can not work on addcolumn , What alternative way to implement my code.
Please support me , Thank you in advance.
2
Answers
You can use a variable
You can structure you Datatable like this and add conditional columns.