Closed CWSPS154 closed 1 year ago
Could you give some example for how to use the method makeIfCan
Use case: column or field is only visible for admin?
Column::makeIfCan('admin', 'secret_column'),
On Editor,
Select::makeIfCan('admin', 'role')
@yajra Thank You for you reply.
For me, I have to apply a Gate Gate::allows('have-access','create_role')
in the makeIfCan, but there is no option to pass the the argument for the gate option
You can also use Column::makeIf(Gate::allows('have-access','create_role'), 'column')
How we can use for a computed column Column::computed('action') ->title(__('datatable.action')) ->exportable(false) ->printable(false) ->width(60),
Computed is just a shortcut for searchable=false
and orderable=false
.
@yajra When I use this code for action column, it return this error DataTables warning: table id=permission-table - Requested unknown parameter '6' for row 0, column 6. For more information about this error, please see http://datatables.net/tn/4
https://github.com/yajra/laravel-datatables-html/blob/3aaf1c19eb70713858e0ff88ac872e3386bbb4c1/src/Html/HasAuthorizations.php#L57 Core Class - Illuminate\Foundation\Auth\Access\Authorizable Yajra\DataTables\Html\HasAuthorizations::makeIfCan()