我的控制器中有此代码
public function index()
{
if(request()->ajax())
{
return datatables()->of(User::latest()->get())
->addColumn('action', function($data){
$button = '<a href="#" name="show" id="'.$data->id.'" class="show-modal"><i title="Visualizar" style="color: #00897b;" class="material-icons">visibility</i></a>';
$button .= ' ';
$button .= '<a href="#" name="edit" id="'.$data->id.'" class="edit-modal"><i title="Editar" style="color: black;" class="material-icons">edit</i></a>';
$button .= ' ';
$button .= '<a href="#" name="delete" id="'.$data->id.'" class="delete-modal"><i title="Excluir" style="color: red;" class="material-icons">delete</i></a>';
return $button;
})
->rawColumns(['action'])
->make(true);
}
return view('admin.usuarios.index');
}
我可以在按钮中使用辅助功能@can吗?像这样:
$button = '@can ('isAdmin') <a href="#" name="show" id="'.$data->id.'" class="show-modal"><i title="Visualizar" style="color: #00897b;" class="material-icons">visibility</i></a> @endCan';